| | |
| | | /* 支付宝普通授权登录 */ |
| | | export const getUserId = (params, config = {}) => http.get(URL + '/service-merchant/v1/web/h5PayAli/getUserIdByCode', |
| | | params, config = {}); |
| | | |
| | | export const userLogin = (params, config = {}) => { |
| | | let path = '/service-merchant/v1/web/aggregatePayAllin/getOpenId' |
| | | if(params.platform==5){ |
| | | path = '/service-merchant/v1/web/h5PayAli/getUserIdByCode' |
| | | } |
| | | return http.get(URL + path, |
| | | params, config = {}) |
| | | }; |
| | | /* 获取用户积分 */ |
| | | export const queryScore = (params, config = {}) => http.get(URL + |
| | | '/service-merchant/v1/web/aggregatePayAllin/queryScore', params, config = {}); |
| | |
| | | /* 获取首绑有礼 */ |
| | | export const headBand = (params, config = {}) => http.get(URL + |
| | | '/service-shop/v1/shop/wechat/activity/headBand/detail', |
| | | params, config = {}); |
| | | params, config = {}); |
| | |
| | | }) |
| | | }, |
| | | // 微信支付 |
| | | wxPay(res) { |
| | | setTimeout(() => { |
| | | wx.chooseWXPay({ |
| | | timestamp: res.timeStamp, // 支付签名时间戳 |
| | | nonceStr: res.nonceStr, // 支付签名随机串,不长于 32 位 |
| | | package: res.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*) |
| | | signType: res.signType, // 微信支付V3的传入 RSA ,微信支付V2的传入格式与V2统一下单的签名格式保持一致 |
| | | paySign: res.paySign, // 支付签名 |
| | | success: function(res) { |
| | | // 支付成功后的回调函数 |
| | | uni.navigateTo({ |
| | | url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON |
| | | .stringify(this.youHuiInfo)}` |
| | | }) |
| | | } |
| | | }); |
| | | }, 200) |
| | | }, |
| | | wxPay(res) { |
| | | /*setTimeout(() => { |
| | | wx.chooseWXPay({ |
| | | timestamp: res.timeStamp, // 支付签名时间戳 |
| | | nonceStr: res.nonceStr, // 支付签名随机串,不长于 32 位 |
| | | package: res.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*) |
| | | signType: res.signType, // 微信支付V3的传入 RSA ,微信支付V2的传入格式与V2统一下单的签名格式保持一致 |
| | | paySign: res.paySign, // 支付签名 |
| | | success: function(res) { |
| | | // 支付成功后的回调函数 |
| | | uni.navigateTo({ |
| | | url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON |
| | | .stringify(this.youHuiInfo)}` |
| | | }) |
| | | } |
| | | }); |
| | | }, 200)*/ |
| | | setTimeout(() => { |
| | | WeixinJSBridge.invoke( |
| | | 'getBrandWCPayRequest', { |
| | | "appId": res.appId, //公众号ID,由商户传入 |
| | | "timeStamp": res.timeStamp, //时间戳,自1970年以来的秒数 |
| | | "nonceStr": res.nonceStr, //随机串 |
| | | "package": res.package, |
| | | "signType": res.signType, //微信签名方式: |
| | | "paySign": res.paySign //微信签名 |
| | | }, |
| | | (res) => { |
| | | if (res.err_msg == "get_brand_wcpay_request:ok") { |
| | | // 使用以上方式判断前端返回,微信团队郑重提示: |
| | | //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 |
| | | uni.navigateTo({ |
| | | url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON |
| | | .stringify(this.youHuiInfo)}` |
| | | }) |
| | | } |
| | | }); |
| | | }, 200) |
| | | }, |
| | | //支付宝支付 |
| | | aliPay(res) { |
| | | ap.tradePay({ |
| | |
| | | <view class="mask" @click="showBord"></view> |
| | | </view> |
| | | <view class="u-font-28 color-666 u-m-t-60">选择支付方式</view> |
| | | <u-radio-group v-model="bankCardId" placement="column"> |
| | | <u-radio-group v-model="payWay" placement="column"> |
| | | <view v-if="platform == 5" class="u-border-bottom u-p-v-20 u-flex u-row-between"> |
| | | <image src="@/static/imgs/pay-zfb.png" class="pay-icon"></image> |
| | | <view class="flex-1"> |
| | |
| | | <navigator v-if="isNew" class="reg-btn" :url="'/pages/pay/register?cid='+cid"> |
| | | <image src="/static/register-btn.png" mode=""></image> |
| | | </navigator> |
| | | <!-- <view class="btn"> |
| | | <wx-open-launch-weapp class="wx-app" id="launch-btn" appid="wxfc579973fbdde096" |
| | | username="gh_3676c3af5dda" path="pages/index/index" env-version="release"> |
| | | <script type="text/wxtag-template"> |
| | | <style> |
| | | .btn { |
| | | border: none; |
| | | position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | left: 0; |
| | | width: 100%; |
| | | border-radius: 50px; |
| | | text-align: center; |
| | | line-height: 100%; |
| | | color: #BF3B00; |
| | | font-size: 18px; |
| | | font-weight: 600; |
| | | background: linear-gradient(180deg, rgba(253, 222, 95, 1) 0%, rgba(254, 172, 31, 1) 71%, rgba(254, 186, 40, 1) 100%); |
| | | } |
| | | </style> |
| | | <button class="btn">打开小程序</button> |
| | | </script> |
| | | </wx-open-launch-weapp> |
| | | </view>--> |
| | | </view> |
| | | |
| | | |
| | |
| | | queryShop, |
| | | queryMyDiscount, |
| | | getScoreWorth, |
| | | getOpenId, |
| | | getUserId, |
| | | userLogin, |
| | | queryScore, |
| | | queryMyUseSweepPayMaxCoupon, |
| | | getWechatConfigInfo, |
| | |
| | | this.init() |
| | | } |
| | | if (opt.code || opt.auth_code) { |
| | | let type = this.platform |
| | | let code = opt.code |
| | | if (this.platform == 5) { |
| | | code = opt.auth_code |
| | | } |
| | | this.end++ |
| | | getOpenId({ |
| | | userLogin({ |
| | | platform: this.platform, |
| | | params: { |
| | | code: opt.code |
| | | code |
| | | } |
| | | }).then(res => { |
| | | this.count++ |
| | | if (this.count >= this.end) { |
| | | uni.hideLoading() |
| | | } |
| | | this.token = res.token.accessToken |
| | | uni.setStorageSync(ACCESSTOKEN, res.token.accessToken) |
| | | uni.setStorageSync('IS_NEW', res.isNew) |
| | | this.isNew = res.isNew |
| | | if (!res.isNew) { |
| | | this.getUserInfo() |
| | | } |
| | | this.getToken(res) |
| | | }).catch(() => { |
| | | uni.hideLoading() |
| | | }) |
| | |
| | | this.canReset = true |
| | | }, |
| | | methods: { |
| | | getToken(res){ |
| | | this.count++ |
| | | if (this.count >= this.end) { |
| | | uni.hideLoading() |
| | | } |
| | | this.token = res.token.accessToken |
| | | uni.setStorageSync(ACCESSTOKEN, res.token.accessToken) |
| | | uni.setStorageSync('IS_NEW', res.isNew) |
| | | this.isNew = res.isNew |
| | | if (!res.isNew) { |
| | | this.getUserInfo() |
| | | } |
| | | }, |
| | | radioChange(e, item) { |
| | | this.bordShow = false |
| | | this.payWay = item |
| | |
| | | }, |
| | | //跳转营销页面 |
| | | toDiscount() { |
| | | let toDiscount = false |
| | | //不是会员 |
| | | if (this.isNew) toDiscount = false |
| | | //没有积分、没有优惠券、没有店铺优惠 |
| | | if (this.integral == 0 && !this.couponInfo && this.discount.shopDiscount == 1) toDiscount = false |
| | | const shopInfo = encodeURIComponent(JSON.stringify(this.shopInfo)) |
| | | //有店铺优惠 |
| | | if (this.discount.shopDiscount != 1) { |
| | | toDiscount = true |
| | | } |
| | | if (this.payWay == 3 && (this.shopInfo.bank_pay_use_score_flag || this.shopInfo.bank_pay_use_coupon_flag)) { //银行卡支付 |
| | | toDiscount = true |
| | | } else if ((this.shopInfo.use_score_flag && this.shopInfo.app_pay_use_score_flag) || (this.shopInfo.user_coupon_flag && this.shopInfo.app_pay_use_coupon_flag)) { |
| | | toDiscount = true |
| | | if (!this.isNew) { //是会员 |
| | | if (this.integral > 0 || this.couponInfo) { //有优惠券或积分 |
| | | if (this.payWay == 3 && (this.shopInfo.bank_pay_use_score_flag || this.shopInfo |
| | | .bank_pay_use_coupon_flag)) { //银行卡支付 |
| | | |
| | | uni.navigateTo({ |
| | | url: `/pages/pay/discountpay?shopInfo=${shopInfo}&integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}` |
| | | }) |
| | | return false |
| | | } else if ((this.shopInfo.use_score_flag && this.shopInfo.app_pay_use_score_flag) || (this |
| | | .shopInfo |
| | | .user_coupon_flag && this.shopInfo.app_pay_use_coupon_flag)) { |
| | | uni.navigateTo({ |
| | | url: `/pages/pay/discountpay?shopInfo=${shopInfo}&integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}` |
| | | }) |
| | | return false |
| | | } else if (this.discount.shopDiscount != 1) { |
| | | uni.navigateTo({ |
| | | url: `/pages/pay/discountpay?shopInfo=${shopInfo}&integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}` |
| | | }) |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | } else if (this.discount.shopDiscount != 1) { |
| | | uni.navigateTo({ |
| | | url: `/pages/pay/discountpay?shopInfo=${shopInfo}&integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}` |
| | | }) |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | } else { |
| | | toDiscount = false |
| | | return true |
| | | } |
| | | uni.navigateTo({ |
| | | url: `/pages/pay/discountpay?shopInfo=${shopInfo}&integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}` |
| | | }) |
| | | return toDiscount |
| | | }, |
| | | //确认支付 |
| | | pay() { |
| | |
| | | }, |
| | | // 微信支付 |
| | | wxPay(res) { |
| | | setTimeout(() => { |
| | | /*setTimeout(() => { |
| | | wx.chooseWXPay({ |
| | | timestamp: res.timeStamp, // 支付签名时间戳 |
| | | nonceStr: res.nonceStr, // 支付签名随机串,不长于 32 位 |
| | |
| | | }) |
| | | } |
| | | }); |
| | | }, 200)*/ |
| | | |
| | | setTimeout(() => { |
| | | WeixinJSBridge.invoke( |
| | | 'getBrandWCPayRequest', { |
| | | "appId": res.appId, //公众号ID,由商户传入 |
| | | "timeStamp": res.timeStamp, //时间戳,自1970年以来的秒数 |
| | | "nonceStr": res.nonceStr, //随机串 |
| | | "package": res.package, |
| | | "signType": res.signType, //微信签名方式: |
| | | "paySign": res.paySign //微信签名 |
| | | }, |
| | | (res) => { |
| | | if (res.err_msg == "get_brand_wcpay_request:ok") { |
| | | // 使用以上方式判断前端返回,微信团队郑重提示: |
| | | //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 |
| | | uni.navigateTo({ |
| | | url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON |
| | | .stringify(this.youHuiInfo)}` |
| | | }) |
| | | } |
| | | }); |
| | | }, 200) |
| | | }, |
| | | //支付宝支付 |