支付宝兼容,排队预约修改,订单逻辑修改

This commit is contained in:
GaoHao
2024-09-24 15:22:34 +08:00
parent 861e97b775
commit 5f03e44701
31 changed files with 823 additions and 737 deletions

View File

@@ -1,13 +1,18 @@
<template>
<!-- 店铺详情 -->
<u-popup :show="show" :round="20" overlayOpacity="0.8" mode="bottom" @close="showClose" height="500">
<u-popup :show="memberOpen" :round="20" overlayOpacity="0.8" mode="bottom" @close="showClose" height="500">
<view class="register-member-wrap">
<view class="register-title">欢迎加入{{shopUserInfo.shopName?shopUserInfo.shopName:'本店'}}</view>
<view class="register-tip">请完善个人信息完成会员注册</view>
<view class="register-content">
<view class="reg-head">
<view class="reg-head-img">
<!-- #ifdef MP-WEIXIN -->
<button class="reg-head-img" type="default" open-type="chooseAvatar" @chooseavatar="uploadImg">
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<button class="reg-head-img" type="default" open-type="chooseAvatar" @chooseAvatar="uploadImg">
<!-- #endif -->
<image class="reg-head-img" :src="userHeadImg || 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/menber/head_default.png'" mode="aspectFill"></image>
</button>
</view>
@@ -37,7 +42,13 @@
<view class="reg-cell">
<view class="lable">手机号</view>
<u-input class="value" v-model="telephone" fontSize="14px" type="text" input-align="left" readonly placeholder="获取微信手机号" :custom-style="{border:'none'}" placeholder-style="color:#999;font-size: 28rpx"/>
<!-- #ifdef MP-WEIXIN -->
<button class="getPhone" open-type="getPhoneNumber" @getphonenumber="getPhone">
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<button class="getPhone" open-type="getAuthorize" scope='phoneNumber' @getAuthorize="getPhone" @error="getPhoneError">
<!-- #endif -->
<view class="text">{{phonetitle || '获取微信手机号'}}</view>
</button>
</view>
@@ -64,7 +75,18 @@
<script>
export default {
props: ['show',"shopId"],
props: {
shopId: {
type: String,
default: ''
},
show: {
type: Boolean,
default: false,
},
},
data() {
return {
value1: Number(new Date()),
@@ -76,10 +98,13 @@
birthDay: "",
isProtocol: false,
shopUserInfo: null,
memberOpen: false,
}
},
mounted() {
console.log(13)
this.shopId = uni.cache.get('shopId')
console.log(this.memberOpen)
this.init()
// console.log(this.userInfo)
// this.userId = this.userInfo.id;
@@ -88,14 +113,18 @@
methods: {
async init() {
let res = await this.api.shopUserInfo({
"shopId": this.shopId,
"userId": uni.cache.get('userInfo').id,
})
console.log(res)
if (res.code == 0) {
this.shopUserInfo = res.data;
if ( uni.cache.get('shopUserInfo') && this.shopId == uni.cache.get('shopUserInfo').id ) {
this.shopUserInfo = uni.cache.get('shopUserInfo');
} else {
let res = await this.api.shopUserInfo({
"shopId": this.shopId,
"userId": uni.cache.get('userInfo').id,
})
if (res.code == 0) {
this.shopUserInfo = res.data;
}
}
this.memberOpen = this.shopUserInfo.isVip == 0 ? true : false;
this.userHeadImg = this.shopUserInfo.headImg;
this.nickName = this.shopUserInfo.nickName && this.shopUserInfo.nickName != '微信用户' ? this.shopUserInfo.nickName : '';
this.telephone = this.shopUserInfo.telephone;
@@ -126,15 +155,12 @@
* @param {Object} e
*/
uploadImg(e) {
console.log(e)
const {
avatarUrl
} = e.detail
console.log(e)
console.log(e.detail)
// this.userHeadImg = avatarUrl
uni.uploadFile({
url: 'https://wxcashiertest.sxczgkj.cn/cashierService/common/upload',
url: uni.conf.baseUrl + '/common/upload',
// url: uni.conf.baseUrl + '/common/upload',
filePath: avatarUrl,
header: {
@@ -150,6 +176,9 @@
let { data } = JSON.parse(uploadFileRes.data)
this.userHeadImg = data
},
fail: (res) => {
console.log(res)
}
});
},
@@ -168,6 +197,7 @@
* @param {Object} d
*/
async getPhone(d) {
// #ifdef MP-WEIXIN
if (d.detail.iv) {
uni.login({
provider: 'weixin',
@@ -182,6 +212,32 @@
}
})
}
// #endif
// #ifdef MP-ALIPAY
// 支付宝小程序环境
my.getAuthCode({
scopes: 'auth_user',
success: (res) => {
console.log(res)
my.getPhoneNumber({
success: async (data) => {
console.log(data)
let res = await this.api.userwxlogins({
code: res.authCode,
encryptedData: d.response,
iv: d.detail.iv,
})
this.phonetitle = res.data.substr(0, 3) + "****" + res.data.substr(7)
this.mobile = res.data;
}
});
}
});
// #endif
},
getPhoneError (e) {
console.log(e)
},
/**
@@ -252,6 +308,7 @@
if ( res.code == 0 ) {
this.$emit('getRegisterMember', false)
this.memberOpen = false;
let res = await this.api.loginwxuserInfo({
userId: uni.cache.get('userInfo').id
})
@@ -330,12 +387,19 @@
}
}
.getPhone{
line-height: initial;
background-color: none;
border: 2rpx solid #E3AD7F;
color: #E3AD7F;
font-size: 28rpx;
padding: 5rpx 10rpx;
// #ifdef MP-ALIPAY
padding-top: 0;
display: initial;
height: 70rpx;
line-height: 70rpx;
box-sizing: border-box;
border-radius: 5rpx;
// #endif
}
}
.agreement{