| | |
| | | import '@/pages/subComponents/uview-components/uview-ui'; |
| | | import tool from "@/pages/tabbar/user/utils/tool.vue"; |
| | | import { getSTSToken } from "@/api/common.js"; |
| | | import { getCouponsNum, getFootprintNum } from "@/api/members.js"; |
| | | import { getCouponsNum, getFootprintNum,bindMemberAndStore } from "@/api/members.js"; |
| | | import { getUserWallet } from "@/api/members"; |
| | | import configs from '@/config/config' |
| | | import storage from '@/utils/storage.js' |
| | | import { getSessionId, userAction } from "@/api/userAction.js"; |
| | | export default { |
| | | components: { |
| | | tool |
| | |
| | | couponNum: "", |
| | | footNum: "", |
| | | walletNum: "", |
| | | pageSessionNo:"", |
| | | actionParam:{ |
| | | sessionId:'', |
| | | actionType:"PAGE", |
| | | joinType:"SELF", |
| | | pageCode:"TBA_BAR_MY", |
| | | pageParams:"{}", |
| | | pageStatus:"JOIN", |
| | | pageType:"DETAIL" |
| | | } |
| | | }; |
| | | }, |
| | | onLoad() { |
| | | onLoad(option) { |
| | | console.log('-----------分享出的数据---------->', option) |
| | | let shareStoreId = null; |
| | | let shareTime = null; |
| | | // 检查是否存在q参数 |
| | | if (option.q) { |
| | | // 双重解码:微信对URL进行了两次编码 |
| | | const decodedUrl = decodeURIComponent(decodeURIComponent(option.q)); |
| | | console.log('原始URL:', decodedUrl); |
| | | |
| | | // 解析URL中的查询参数 |
| | | const params = this.parseUrlParams(decodedUrl); |
| | | shareStoreId = params.shareStoreId; |
| | | try { |
| | | // 将数据存储到本地缓存 |
| | | uni.setStorageSync('shareStoreId', shareStoreId); |
| | | //创建一个扫码的时间 |
| | | // 获取当前时间并格式化为 yyyy-MM-dd HH:mm:ss |
| | | const now = new Date(); |
| | | const year = now.getFullYear(); |
| | | const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要+1 |
| | | const day = String(now.getDate()).padStart(2, '0'); |
| | | const hours = String(now.getHours()).padStart(2, '0'); |
| | | const minutes = String(now.getMinutes()).padStart(2, '0'); |
| | | const seconds = String(now.getSeconds()).padStart(2, '0'); |
| | | |
| | | shareTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
| | | uni.setStorageSync('shareTime', shareTime); |
| | | console.log('数据存储成功'); |
| | | } catch (e) { |
| | | console.error('存储失败:', e); |
| | | } |
| | | }else{ |
| | | shareStoreId = uni.getStorageSync('shareStoreId'); |
| | | shareStoreId = uni.getStorageSync('shareTime'); |
| | | console.log('从缓存读取参数:', { shareStoreId, shareTime }); |
| | | // this.bindMemberAndStore(shareStoreId, shareTime) |
| | | if (shareStoreId && shareTime) { |
| | | console.log('检测到有效参数,调用后端接口'); |
| | | this.bindMemberAndStore(shareStoreId, shareTime); |
| | | } else { |
| | | console.log('无有效参数,执行正常逻辑'); |
| | | } |
| | | } |
| | | this.initCOS() |
| | | }, |
| | | onUnload() { |
| | | let param = Object.assign({}, this.actionParam); |
| | | if (this.sendOnShow)return |
| | | param.pageStatus = "LEAVE" |
| | | userAction(param) |
| | | }, |
| | | onHide() { |
| | | this.startHidenTime = Date.now() |
| | | let param =Object.assign({}, this.actionParam); |
| | | this.sendOnShow = true; |
| | | param.pageStatus = "LEAVE" |
| | | userAction(param) |
| | | }, |
| | | onLoad(options) { |
| | | this.actionParam.pageParams = JSON.stringify(options) |
| | | this.initCOS() |
| | | }, |
| | | onShow() { |
| | | getSessionId().then(res=>{ |
| | | this.pageSessionNo = res.data.data |
| | | this.actionParam.sessionId = res.data.data |
| | | if(this.pageSessionNo){ |
| | | let param = Object.assign({}, this.actionParam); |
| | | param.sessionId = this.pageSessionNo |
| | | userAction(param) |
| | | } |
| | | }) |
| | | this.userInfo = this.$options.filters.isLogin() || {}; |
| | | if (this.$options.filters.isLogin("auth")) { |
| | | this.getUserOrderNum(); |
| | |
| | | |
| | | mounted() { }, |
| | | methods: { |
| | | async bindMemberAndStore(shareStoreId, shareTime){ |
| | | let form ={ |
| | | shareStoreId: shareStoreId, |
| | | shareTime: shareTime |
| | | } |
| | | // let form ={ |
| | | // shareStoreId: "1376433565247471616", |
| | | // shareTime: "2025-09-26 16:18:00" |
| | | // } |
| | | try { |
| | | const res = await bindMemberAndStore(form); |
| | | if(res.statusCode === 200){ |
| | | //清除缓存 |
| | | uni.removeStorageSync('shareStoreId'); |
| | | uni.removeStorageSync('shareTime'); |
| | | } |
| | | } |
| | | catch(error) { |
| | | console.error('出错:', error); |
| | | }; |
| | | }, |
| | | // goTOSuccess(){ |
| | | // uni.redirectTo({ |
| | | // url:"/pages/cart/payment/success?paymentMethod=WECHAT" + |
| | |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import url("/pages/subComponents/static/bgStyle.css"); |
| | | html, |
| | | body { |
| | | overflow: auto; |
| | |
| | | background-size: cover; |
| | | border-bottom-left-radius: 30rpx; |
| | | border-bottom-right-radius: 30rpx; |
| | | background-image: url("/pages/subComponents/static/img/main-bg.png"); |
| | | background-image: var(--main-bg); |
| | | background-position: bottom; |
| | | background-repeat: no-repeat; |
| | | color: #ffffff; |