This commit is contained in:
魏啾
2024-08-08 16:50:30 +08:00
3 changed files with 149 additions and 42 deletions

View File

@@ -87,8 +87,9 @@
url: '/pages/member/activatedmemberone?shopId=' + uni.cache.get('shopUser')
})
} else {
uni.pro.navigateTo('member/memberdetails', {
shopId_id: uni.cache.get('shopUser'),
uni.pro.navigateTo('member/index', {
shopId: uni.cache.get('shopUser'),
type: 'index',
})
}
} else {

View File

@@ -41,7 +41,8 @@
this.switchdata = false
uni.cache.set('userInfo', resdata .data);
uni.pro.redirectTo('/pages/member/index', {
shopId: uni.cache.get('shopUser')
shopId: this.shopId,
type: 'index'
})
}

View File

@@ -36,13 +36,13 @@
</view>
</view>
<view>
</view>
<view class="rechargeBox">
<view class="recharge" @tap="$u.debounce(userbalancerechangesub, 500)">立即充值</view>
</view>
<!-- 开通会员 -->
<u-popup :show="memberOpen" :closeOnClickOverlay="true" overlayOpacity="0.8" :round="20" mode="bottom" @close="memberCancel" height="500">
<view class="u-popup-content">
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/wkthuiyuanbg.png" class="imgstyle" mode=""></image>
<button class="btnclass" open-type="getPhoneNumber" @getphonenumber="sumbit">立即开通 </button>
</view>
</u-popup>
</view>
@@ -59,25 +59,120 @@
amount: '',
userInfo: {},
shopId: '',
cardManageList: [
{name: "明细",icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/menber/detail.png"},
{name: "管理",icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/menber/manage.png"}
],
tokenShow: true,
memberOpen: false,
usershopUserinfo: null,
}
},
onLoad(e) {
this.shopId = e.shopId
if (e.type == 'list') { //从列表进来的
this.paygetShopByMember(e.shopId)
} else {
this.paygetShopByMember(e.shopId)
console.log(e)
if ( e.type == 'list' || e.type == 'index') {
this.shopId = e.shopId;
this.init();
}
this.paygetActive(e.shopId) //列表
if (e.q) {
this.shopId = this.getQueryString(decodeURIComponent(e.q), 'shopId')
if (!uni.cache.get('token')) {
uni.login({
provider: 'weixin',
success: async (data) => {
try {
uni.getUserInfo({
provider: 'weixin',
success: async (infoRes) => {
uni.cache.set('weixincode', data.code);
let res = await this.api.userwxlogin({
code: uni.cache.get('weixincode'), //临时登录凭证
rawData: infoRes.rawData
})
if (res.code == 0) {
uni.cache.set('token', res.data.token);
uni.cache.set('miniAppOpenId', res.data.userInfo
.miniAppOpenId)
uni.cache.set('userInfo', res.data.userInfo);
this.tokenShow = false;
this.init();
}
},
fail: (err) => {}
});
} catch (e) {}
}
});
} else {
this.init();
}
}
console.log(this.shopId)
},
methods: {
async init() {
let res = await this.api.shopUserInfo({
"shopId": this.shopId,
"userId": uni.cache.get('userInfo').id,
})
if (res.code == 0) {
this.usershopUserinfo = res.data
}
if ( this.usershopUserinfo.isVip == 0 ) {
this.memberOpen = true;
return;
}
this.paygetShopByMember(this.shopId)
this.paygetActive()
},
memberCancel () {
let pages = getCurrentPages()
if ( pages.length > 1) {
uni.navigateBack()
} else {
uni.exitMiniProgram({
success: function () {
console.log('退出成功');
},
fail: function () {
console.log('退出失败');
}
});
}
},
sumbit(d) {
if (d.detail.iv) {
uni.login({
provider: 'weixin',
success: async (data) => {
let res = await this.api.userwxlogins({
code: data.code,
encryptedData: d.detail.encryptedData,
iv: d.detail.iv,
shopId: this.shopId
})
if (res.code == 0) {
let resdata = await this.api.loginwxuserInfo({
userId: uni.cache.get('userInfo').id
})
if (resdata.code == 0) {
uni.cache.set('userInfo', resdata .data);
this.memberOpen = false
this.paygetShopByMember(this.shopId)
this.paygetActive()
}
}
}
})
}
},
getQueryString(url, name) { //解码
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
var r = url.substr(1).match(reg)
if (r != null) {
return r[2]
}
return null;
},
async paygetShopByMember(w) {
let res = await this.api.paygetShopByMember({
page: 1,
@@ -93,6 +188,7 @@
page: 1,
pageSize: 10
})
try {
this.listdata = res.data.list
this.amount = res.data.list[0].minNum
@@ -301,27 +397,36 @@
padding-left: 20rpx;
}
}
.rechargeBox{
width: 100%;
padding: 16rpx 28rpx 84rpx 28rpx;
background-color: #fff;
position: fixed;
left: 0;
bottom: 0;
.recharge {
width: 100%;
height: 90rpx;
line-height: 90rpx;
text-align: center;
font-weight: bold;
font-size: 36rpx;
color: #FFFFFF;
border-radius: 12rpx;
background: #E3AD7F;
}
.imgstyle {
width: 694rpx;
height: 414rpx;
margin: 70rpx auto;
}
.btnclass {
width: 694rpx;
height: 90rpx;
line-height: 90rpx;
background: #6D89A4;
border-radius: 12rpx 12rpx 12rpx 12rpx;
text-align: center;
margin: auto;
font-family: PingFang SC, PingFang SC;
font-weight: bold;
font-size: 36rpx;
color: #FFFFFF;
bottom: 50rpx;
position: absolute;
left: 0;
right: 0;
margin: auto;
}
.u-popup-content {
height: 80vh; /* 设置高度为视口高度的50% */
width: 100%;
/* 其他样式 */
}
}
</style>