Merge remote-tracking branch 'remotes/old/zmj' into old

This commit is contained in:
jia 2023-09-13 18:55:13 +08:00
commit c883775f4d
3 changed files with 487 additions and 333 deletions

View File

@ -1,351 +1,365 @@
<template> <template>
<view> <view>
<view class='mask' v-if='isShowAuth && code' @click='close'></view> <view class='mask' v-if='isShowAuth && code' @click='close'></view>
<view class='Popup' v-if='isShowAuth && code' :style="'top:'+top+'px;'"> <view class='Popup' v-if='isShowAuth && code' :style="'top:'+top+'px;'">
<!-- <view class="logo-auth"> <!-- <view class="logo-auth">
<image class="image" :src='routine_logo' mode="aspectFit"></image> <image class="image" :src='routine_logo' mode="aspectFit"></image>
</view> --> </view> -->
<!--#ifdef H5--> <!--#ifdef H5-->
<text v-if="isWeixin" class='title'>授权提醒</text> <text v-if="isWeixin" class='title'>授权提醒</text>
<text v-else class='title'>{{title}}</text> <text v-else class='title'>{{title}}</text>
<!--#endif--> <!--#endif-->
<!--#ifdef APP-PLUS--> <!--#ifdef APP-PLUS-->
<text class='title'>用户登录</text> <text class='title'>用户登录</text>
<!--#endif--> <!--#endif-->
<!--#ifdef MP--> <!--#ifdef MP-->
<text class='title'>{{title}}</text> <text class='title'>{{title}}</text>
<!--#endif--> <!--#endif-->
<!--#ifdef H5--> <!--#ifdef H5-->
<text v-if="isWeixin" class='tip'>请授权头像等信息以便为您提供更好的服务</text> <text v-if="isWeixin" class='tip'>请授权头像等信息以便为您提供更好的服务</text>
<text v-else class='tip'>{{info}}</text> <text v-else class='tip'>{{info}}</text>
<!--#endif--> <!--#endif-->
<!--#ifdef APP-PLUS--> <!--#ifdef APP-PLUS-->
<text class='tip'>请登录将为您提供更好的服务</text> <text class='tip'>请登录将为您提供更好的服务</text>
<!--#endif--> <!--#endif-->
<!--#ifdef MP--> <!--#ifdef MP-->
<text class='tip'>{{info}}</text> <text class='tip'>{{info}}</text>
<!--#endif--> <!--#endif-->
<view class='bottom flex'> <view class='bottom flex'>
<text class='item' @click='close'>随便逛逛</text> <text class='item' @click='close'>随便逛逛</text>
<!-- #ifdef MP --> <!-- #ifdef MP -->
<button class="item grant" hover-class="none" @tap="getUserProfile"><text class="text">去授权</text></button> <button class="item grant" hover-class="none" @tap="getUserProfile"><text
<!-- #endif --> class="text">去授权</text></button>
<!-- #ifdef APP-PLUS --> <!-- #endif -->
<button class="item grant" @tap="toWecahtAuth"> <!-- #ifdef APP-PLUS -->
<text class="text">去登录</text> <button class="item grant" @tap="toWecahtAuth">
</button> <text class="text">去登录</text>
<!-- #endif --> </button>
<!-- #ifdef H5 --> <!-- #endif -->
<button class="item grant" @tap="toWecahtAuth"> <!-- #ifdef H5 -->
<text v-if="isWeixin" class="text">去授权</text> <button class="item grant" @tap="toWecahtAuth">
<text v-else class="text">去登录</text> <text v-if="isWeixin" class="text">去授权</text>
</button> <text v-else class="text">去登录</text>
<!-- #endif --> </button>
</view> <!-- #endif -->
</view> </view>
<!-- #ifdef MP --> </view>
<editUserModal :isShow="editModal" @closeEdit="closeEdit" @editSuccess="editSuccess"></editUserModal> <!-- #ifdef MP -->
<!-- #endif --> <editUserModal :isShow="editModal" @closeEdit="closeEdit" @editSuccess="editSuccess"></editUserModal>
</view> <!-- #endif -->
</view>
</template> </template>
<script> <script>
const app = getApp(); const app = getApp();
import Cache from '../utils/cache'; import Cache from '../utils/cache';
import { import {
getLogo, getLogo,
commonAuth commonAuth
} from '../api/public'; } from '../api/public';
import { LOGO_URL, USER_INFO, EXPIRES_TIME } from '../config/cache'; import {
import { mapGetters } from 'vuex'; LOGO_URL,
import Routine from '../libs/routine'; USER_INFO,
import { configMap } from '@/utils/index'; EXPIRES_TIME
import Auth from '../libs/wechat'; } from '../config/cache';
import { toLogin } from '../libs/login'; import {
// #ifdef MP mapGetters
import editUserModal from '@/components/eidtUserModal/index.vue' } from 'vuex';
// #endif import Routine from '../libs/routine';
export default { import {
name: 'Authorize', configMap
props: { } from '@/utils/index';
isAuto: { import Auth from '../libs/wechat';
type: Boolean, import {
default: true toLogin
}, } from '../libs/login';
isGoIndex: { // #ifdef MP
type: Boolean, import editUserModal from '@/components/eidtUserModal/index.vue'
default: true // #endif
}, export default {
isShowAuth: { name: 'Authorize',
type: Boolean, props: {
default: false isAuto: {
} type: Boolean,
}, default: true
components: { },
// #ifdef MP isGoIndex: {
editUserModal type: Boolean,
// #endif default: true
}, },
data() { isShowAuth: {
return { type: Boolean,
title: '用户登录', default: false
info: '请登录,将为您提供更好的服务!', }
//#ifdef H5 },
isWeixin: this.$wechat.isWeixin(), components: {
//#endif // #ifdef MP
//#ifdef MP editUserModal
title: '授权提醒', // #endif
info: '请授权头像等信息,以便为您提供更好的服务!', },
//#endif data() {
canUseGetUserProfile: false, return {
code: null, title: '用户登录',
top: 0, info: '请登录,将为您提供更好的服务!',
mp_is_new: this.$Cache.get('MP_VERSION_ISNEW') || false, //#ifdef H5
editModal: false, // isWeixin: this.$wechat.isWeixin(),
} //#endif
}, //#ifdef MP
computed: { title: '授权提醒',
...mapGetters(['isLogin', 'userInfo', 'viewColor']), info: '请授权头像等信息,以便为您提供更好的服务!',
...configMap(['routine_logo']) //#endif
}, canUseGetUserProfile: false,
watch: { code: null,
isLogin(n) { top: 0,
n === true && this.$emit('onLoadFun', this.userInfo); mp_is_new: this.$Cache.get('MP_VERSION_ISNEW') || false,
}, editModal: false, //
isShowAuth(n) { }
this.getCode(this.isShowAuth) },
} computed: {
}, ...mapGetters(['isLogin', 'userInfo', 'viewColor']),
created() { ...configMap(['routine_logo'])
// console.log('title' + this.title) },
this.top = uni.getSystemInfoSync().windowHeight / 2 - 70 watch: {
if (wx.getUserProfile) { isLogin(n) {
this.canUseGetUserProfile = true n === true && this.$emit('onLoadFun', this.userInfo);
} },
this.setAuthStatus(); isShowAuth(n) {
this.getCode(this.isShowAuth) this.getCode(this.isShowAuth)
}, }
methods: { },
// #ifdef MP created() {
editSuccess() { // console.log('title' + this.title)
this.editModal = false this.top = uni.getSystemInfoSync().windowHeight / 2 - 70
this.$emit('onLoadFun', this.userInfo); if (wx.getUserProfile) {
}, this.canUseGetUserProfile = true
closeEdit() { }
this.editModal = false this.setAuthStatus();
}, this.getCode(this.isShowAuth)
// #endif },
setAuthStatus() { methods: {
//#ifdef MP // #ifdef MP
Routine.authorize().then(res => { editSuccess() {
if (res.islogin === false) this.editModal = false
this.$emit('onLoadFun', this.userInfo); this.$emit('onLoadFun', this.userInfo);
}).catch(res => { },
if (this.isAuto) closeEdit() {
this.$emit('authColse', true); this.editModal = false
}) },
//#endif // #endif
}, setAuthStatus() {
getCode(n) { //#ifdef MP
// #ifdef MP Routine.authorize().then(res => {
if (n) { if (res.islogin === false)
uni.showLoading({ this.$emit('onLoadFun', this.userInfo);
title: '正在登录中' }).catch(res => {
}); if (this.isAuto)
Routine.getCode().then(code => { this.$emit('authColse', true);
uni.hideLoading(); })
this.code = code; //#endif
}).catch(e => { },
uni.hideLoading(); getCode(n) {
uni.showToast({ // #ifdef MP
title: '登录失败', if (n) {
duration: 2000 uni.showLoading({
}); title: '正在登录中'
}) });
} else { Routine.getCode().then(code => {
this.code = null; uni.hideLoading();
} this.code = code;
// #endif }).catch(e => {
// #ifndef MP uni.hideLoading();
if (n) { uni.showToast({
this.code = 1; title: '登录失败',
} duration: 2000
// #endif });
}, })
toWecahtAuth() { } else {
toLogin(true); this.code = null;
}, }
getUserProfile() { // #endif
// console.log(11); // #ifndef MP
toLogin(true); if (n) {
uni.navigateTo({ this.code = 1;
url: '/pages/users/login/login_copy' }
}) // #endif
// console.log(22); },
return toWecahtAuth() {
let self = this; toLogin(true);
Routine.getUserProfile() },
.then(res => { getUserProfile() {
let userInfo = res.userInfo; // console.log(11);
userInfo.code = this.code; toLogin(true);
userInfo.spread = app.globalData.spid; //广ID uni.navigateTo({
userInfo.spread_code = app.globalData.code; //广ID url: '/pages/users/login/login_copy'
commonAuth({ })
auth: { // console.log(22);
type: 'routine', return
auth: userInfo let self = this;
} Routine.getUserProfile()
}).then(res => { .then(res => {
if (res.data.status == 200) { let userInfo = res.userInfo;
let time = res.data.result.expires_time - Cache.time(); userInfo.code = this.code;
self.$store.commit('UPDATE_USERINFO', res.data.result.user); userInfo.spread = app.globalData.spid; //广ID
self.$store.commit('LOGIN', { token: res.data.result.token, time: time }); userInfo.spread_code = app.globalData.code; //广ID
self.$store.commit('SETUID', res.data.result.user.uid); commonAuth({
Cache.set(EXPIRES_TIME, res.data.result.expires_time, time); auth: {
Cache.set(USER_INFO, res.data.result.user, time); type: 'routine',
this.$emit('onLoadFun', res.data.result.user); auth: userInfo
if (res.data.result.user.isNew && this.mp_is_new) { }
this.editModal = true; }).then(res => {
} if (res.data.status == 200) {
} else { let time = res.data.result.expires_time - Cache.time();
uni.setStorageSync('auth_token', res.data.result.key); self.$store.commit('UPDATE_USERINFO', res.data.result.user);
return uni.navigateTo({ self.$store.commit('LOGIN', {
url: '/pages/users/login/login_copy' token: res.data.result.token,
}) time: time
} });
}).catch(res => { self.$store.commit('SETUID', res.data.result.user.uid);
uni.hideLoading(); Cache.set(EXPIRES_TIME, res.data.result.expires_time, time);
uni.showToast({ Cache.set(USER_INFO, res.data.result.user, time);
title: res.message, this.$emit('onLoadFun', res.data.result.user);
icon: 'none', if (res.data.result.user.isNew && this.mp_is_new) {
duration: 2000, this.editModal = true;
}
} else {
uni.setStorageSync('auth_token', res.data.result.key);
return uni.navigateTo({
url: '/pages/users/login/login_copy'
})
}
}).catch(res => {
uni.hideLoading();
uni.showToast({
title: res.message,
icon: 'none',
duration: 2000,
}); });
}); });
}) })
.catch(res => { .catch(res => {
uni.hideLoading(); uni.hideLoading();
}); });
}, },
close() { close() {
let pages = getCurrentPages(), let pages = getCurrentPages(),
currPage = pages[pages.length - 1]; currPage = pages[pages.length - 1];
this.$emit('authColse', false); this.$emit('authColse', false);
if (this.isGoIndex) { if (this.isGoIndex) {
uni.switchTab({ uni.switchTab({
url: '/pages/index/index' url: '/pages/index/index'
}); });
} else { } else {
this.$emit('authColse', false); this.$emit('authColse', false);
} }
}, },
} }
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.Popup { .Popup {
flex: 1; flex: 1;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 500rpx; width: 500rpx;
background-color: #fff; background-color: #fff;
position: fixed; position: fixed;
top: 500rpx; top: 500rpx;
left: 125rpx; left: 125rpx;
z-index: 1000; z-index: 1000;
border-radius: 8px; border-radius: 8px;
overflow: hidden; overflow: hidden;
} }
.Popup { .Popup {
.logo-auth { .logo-auth {
z-index: -1; z-index: -1;
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 0%; top: 0%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
width: 150rpx; width: 150rpx;
height: 150rpx; height: 150rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border: 8rpx solid #fff; border: 8rpx solid #fff;
border-radius: 50%; border-radius: 50%;
background: #fff; background: #fff;
} }
.image { .image {
height: 42rpx; height: 42rpx;
margin-top: -54rpx; margin-top: -54rpx;
} }
} }
.Popup .title { .Popup .title {
font-size: 28rpx; font-size: 28rpx;
color: #000; color: #000;
text-align: center; text-align: center;
margin-top: 30rpx; margin-top: 30rpx;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 500rpx; width: 500rpx;
display: flex; display: flex;
} }
.Popup .tip { .Popup .tip {
font-size: 22rpx; font-size: 22rpx;
color: #555; color: #555;
padding: 0 24rpx; padding: 0 24rpx;
margin-top: 25rpx; margin-top: 25rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.Popup .bottom .item { .Popup .bottom .item {
width: 250rpx; width: 250rpx;
height: 80rpx; height: 80rpx;
background-color: #eeeeee; background-color: #eeeeee;
text-align: center; text-align: center;
line-height: 80rpx; line-height: 80rpx;
margin-top: 54rpx; margin-top: 54rpx;
font-size: 24rpx; font-size: 24rpx;
color: #666; color: #666;
.text { .text {
font-size: 24rpx; font-size: 24rpx;
color: #666; color: #666;
} }
} }
.Popup .bottom .item.on { .Popup .bottom .item.on {
width: 500rpx; width: 500rpx;
} }
.flex { .flex {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
} }
.Popup .bottom .item.grant { .Popup .bottom .item.grant {
font-weight: bold; font-weight: bold;
background-color: #E93323; background-color: #E93323;
/* background-color: var(--view-theme); */ /* background-color: var(--view-theme); */
border-radius: 0; border-radius: 0;
padding: 0; padding: 0;
.text { .text {
font-size: 28rpx; font-size: 28rpx;
color: #fff; color: #fff;
} }
} }
.mask { .mask {
position: fixed; position: fixed;
top: 0; top: 0;
right: 0; right: 0;
left: 0; left: 0;
bottom: 0; bottom: 0;
background-color: rgba(0, 0, 0, 0.65); background-color: rgba(0, 0, 0, 0.65);
z-index: 99; z-index: 99;
} }
</style> </style>

View File

@ -256,6 +256,71 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 多规格购物车 -->
<view class="" style="z-index: 9999;">
<u-popup :show="showcartpop" @close="closecartpop" @open="opencartpop">
<view class="sku">
<view class="sku_head">
<view class="sku_head_l">
<u--image :showLoading="true" src="/static/images/BG.png" width="200.09rpx"
height="200.09rpx"></u--image>
</view>
<view class="sku_head_r">
<view class="sku_goods_tit">
fsdfsdfsdfffffffff
</view>
<view class="">
<view class="sku_goods_price">
79.00
</view>
<view class="sku_goods_num">
库存:999
</view>
</view>
</view>
</view>
<view class="sku_size">
<view class="">
尺码
</view>
<view class="">
<text>大号</text>
</view>
</view>
<view class="sku_num">
<view class="">
数量
</view>
<view class="">
<u-number-box v-model="skuNumber" @change="valChange"></u-number-box>
</view>
</view>
<view class="skuaddcart">
加入购物车
</view>
</view>
</u-popup>
</view>
<authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse">
</authorize>
<view class="" :style="`height:${appInfo.bottom}px;background-color:white`"> <view class="" :style="`height:${appInfo.bottom}px;background-color:white`">
</view> </view>
</view> </view>
@ -285,17 +350,26 @@
import { import {
postCartAdd, postCartAdd,
} from '@/api/store.js'; } from '@/api/store.js';
import authorize from '@/components/Authorize';
import {
mapGetters
} from "vuex";
export default { export default {
components: {
authorize,
},
data() { data() {
let src = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/13'; let src = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/13';
return { return {
skuNumber: 0,
showcartpop: false,
trnList: [], trnList: [],
act_cart: false, act_cart: false,
appInfo: {}, appInfo: {},
pocls: "", pocls: "",
type: "", type: "",
act_swiper: "", act_swiper: "",
current: 1, current: 3,
goodsNum: 0, goodsNum: 0,
goodsList: [], goodsList: [],
isEmpty: false, isEmpty: false,
@ -316,6 +390,7 @@
page_num: 1, page_num: 1,
act_img: "", act_img: "",
cartTagInfo: {}, cartTagInfo: {},
isAuto: false,
actList: [{ actList: [{
tit: '综合', tit: '综合',
act: "", act: "",
@ -332,9 +407,14 @@
}], }],
status: "loadmore", status: "loadmore",
flag: false, flag: false,
isShowAuth: false, //
} }
}, },
computed: {
...mapGetters(['isLogin', 'viewColor', 'uid']),
},
// ...mapGetters(['isLogin', 'viewColor', 'uid']),
onLoad(e) { onLoad(e) {
// this.cartFn() // this.cartFn()
this.appInfo = this.$appInfo.safeAreaInsets this.appInfo = this.$appInfo.safeAreaInsets
@ -434,6 +514,23 @@
// }, // },
methods: { methods: {
valChange(e) {
this.valChange = e
},
closecartpop() {
this.showcartpop = false
},
opencartpop() {
this.showcartpop = true
},
//
authColse: function(e) {
this.isShowAuth = e;
},
onLoadFun() {
this.isShowAuth = false;
},
clickSwiperFn(i) { clickSwiperFn(i) {
// console.log(i) // console.log(i)
this.current = i this.current = i
@ -528,6 +625,14 @@
}, },
addcart(item, i) { addcart(item, i) {
// this.showcartpop = true
// return
// console.log(this.isLogin)
if (!this.isLogin) {
this.isAuto = true;
this.isShowAuth = true
return
}
let data = { let data = {
cart_num: 1, cart_num: 1,
@ -635,6 +740,39 @@
} }
} }
.sku {
padding: 20rpx;
.sku_head {
display: flex;
.sku_head_r {
margin-left: 20rpx;
display: flex;
justify-content: space-between;
flex-direction: column;
}
// justify-content;
}
.sku_num {
display: flex;
justify-content: space-between;
}
.skuaddcart {
width: 50vw;
background-color: #FEAB00;
margin: 0 auto;
height: 80rpx;
line-height: 80rpx;
text-align: center;
color: white;
border-radius: 80rpx;
}
}
.flags { .flags {
background-color: red; background-color: red;
z-index: 99999999; z-index: 99999999;
@ -958,7 +1096,7 @@
.card { .card {
width: 720rpx; width: 720rpx;
z-index: 999999; z-index: 99;
// margin:auto; // margin:auto;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);

View File

@ -319,6 +319,8 @@
}, },
onLoad(options) { onLoad(options) {
// uni.hideTabBar() // uni.hideTabBar()
// console.log(this.isLogin, "sdfsdkfhjsdhgfsdf")
// return
this.id = options.id; this.id = options.id;
this.type = options.gtype this.type = options.gtype
@ -617,7 +619,7 @@
this.formData.product_info = [] this.formData.product_info = []
} }
this.productList = [] this.productList = []
this.price = 0; this.price = 0;
if (data.length > 0) { if (data.length > 0) {
this.productList = data; this.productList = data;
for (let i in data) { for (let i in data) {