石广澎
2024-12-23 d5306c224a91b37869d2b96ba03d5a7152bd11e2
feat(支持线上订单支付 ):
4个文件已修改
91 ■■■■ 已修改文件
common/api/index.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/config.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.js 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pay/scanpay.vue 78 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/api/index.js
@@ -13,6 +13,10 @@
export const queryShopByShopId = (params, config = {}) => http.get(URL +
    '/payfour-merchant/v1/web/aggregatePayAllin/queryShopByShopId', params, config)
/* 根据订单id */
export const getOnlineId = (params, config = {}) => http.get(URL +
    '/payfour-merchant/v1/web/aggregatePayAllin/getOnlineId', params, config)
/*统一授权*/
export const userLogin = (params, config = {}) => {
    let path = '/payfour-merchant/v1/web/aggregatePayAllin/getOpenId' //微信授权
common/config.js
@@ -6,14 +6,14 @@
    baseURL: '/dev-api',
    // baseURL: 'http://172.16.2.117:8080',
    wx_appid: 'wx4c146dba764dcb05',
    ali_appid: '2021004149689887'
    ali_appid: '2021004193639959'
}
// 测试
const test = {
    webURL: 'https://sfzf.cpbtsoft.cn',
    baseURL: 'https://sfzf.cpbtsoft.cn/dev-api',
    baseURL: 'https://sfzf.cpbtsoft.cn/prod-api',
    wx_appid: 'wx4c146dba764dcb05',
    ali_appid: '2021004149689887'
    ali_appid: '2021004193639959'
}
// 正式
const prod = {
main.js
@@ -1,6 +1,7 @@
import App from './App'
import Vue from 'vue'
import Vconsole from 'vconsole';
new Vconsole();
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)
pay/scanpay.vue
@@ -66,7 +66,6 @@
                  {{ $utils.accMul(couponInfo.discount, 10) }}折券
                </view>
              </block>
              <view v-else class="u-font-28 lh-1 u-tips-color">请选择</view>
              <u-icon class="u-m-l-10" name="arrow-right" color="#999" size="16"></u-icon>
            </view>
@@ -159,6 +158,7 @@
import {
  queryShopByCid,
  queryShopByShopId,
  getOnlineId,
  userLogin,
  queryUseSweepPayCoupon,
  getWechatConfigInfo,
@@ -178,12 +178,12 @@
      buyerNote: '',
      showRemark: false,
      UNIONID: null,
      payWay: this.$utils.getPlat(), //2 维信 5支付宝 15云闪付
      payWay: this.$utils.getPlat(), //2 微信 5支付宝 15云闪付
      cid: '', //码牌id  C扫B静态码时有
      activityQrcodeId: '', //动态收款码  C扫B动态码时有
      shopId: '', //商户id  C扫B动态码时有
      bordShow: false, // 显示键盘
      orderId: '',
      orderId: '', //冀优邮线上订单id
      shopInfo: {
        cusid: '',
        shopName: '',
@@ -248,6 +248,7 @@
  onLoad(opt) {
    uni.setStorageSync('CID', opt.cid)
    uni.setStorageSync('SHOPID', opt.shopId)
    uni.setStorageSync('ORDERID', opt.orderId)
    uni.setStorageSync('SMONEY', opt.smoney)
    uni.setStorageSync('AQCI', opt.activityQrcodeId)
    this.UNIONID = uni.getStorageSync('UNIONID') || null
@@ -258,9 +259,12 @@
    } else {
      this.bordShow = true
    }
    if (opt.orderId) {
      this.orderId = opt.orderId
      this.init()
    }
    if (opt.activityQrcodeId) {
      this.activityQrcodeId = opt.activityQrcodeId
      // this.getOrderInfo()
    }
    if (opt.shopId) {
      this.shopId = opt.shopId
@@ -399,6 +403,12 @@
          shopId: this.shopId
        }
      }
      if (this.orderId) {
        api = getOnlineId
        params = {
          onlineId: this.orderId
        }
      }
      //获取商铺信息
      api({
        params
@@ -409,6 +419,17 @@
          res.logoImage = config.baseURL + res.logoImage
        }
        this.shopInfo = res
        if(this.orderId){
          this.money = res.totaPrice
          if(res.couponId){
            this.couponInfo = {
              id: res.couponId,
              thresholdValue: res.thresholdValue,
              discount: res.discount,
              discountType: res.discountType,
            }
          }
        }
      }).catch((err) => {
        clearTimeout(timer)
        this.shopInfo.scanFlag = 0
@@ -433,11 +454,39 @@
          wx.ready( ()=> {
            wx.hideAllNonBaseMenuItem();
            if(CHECK_LOCATION){
              this.wxGetLocation()
              this.wxGetLocation(null)
            }
          })
        })
      }
      if(this.payWay == 5){
        ap.hideOptionButton();
        this.apGetLocation(null)
      }
    },
    apGetLocation(callback){
      ap.getLocation((res)=> {
        console.log('apGetLocation',res)
          if(res.latitude){
            this.lat = parseFloat(res.latitude).toFixed(6); // 纬度,浮点数,范围为90 ~ -90
            this.lng = parseFloat(res.longitude).toFixed(6); // 经度,浮点数,范围为180 ~ -180。
            if(callback) callback()
          }else{
            uni.showModal({
              title: '提示',
              content: "获取地理位置失败,无法进行支付!",
              confirmText: '重新授权',
              cancelText: '退出',
              success: ret=>{
                if(ret.confirm){
                  this.apGetLocation(callback)
                }else{
                  this.clickDone()
                }
              }
            })
          }
        })
    },
    wxGetLocation(callback){
      wx.getLocation({
@@ -455,19 +504,21 @@
              cancelText: '退出',
              success: ret=>{
                if(ret.confirm){
                  this.wxGetLocation()
                  this.wxGetLocation(callback)
                }else{
                  this.clickDone()
                }
              }
            })
          }
        }
      });
    },
    // 获取会员相关信息
    showCoupon() {
      if(this.orderId){
        return
      }
      if (this.UNIONID||this.payWay==5) {
        if (uni.$u.test.isEmpty(this.money)) {
          uni.$u.toast('请输入金额!')
@@ -482,6 +533,7 @@
    },
    //获取用户优惠券
    queryUseSweepPayCoupon() {
      //2 微信 5支付宝 15云闪付
      const applyPayWayStr = {
        2: 1,
        5: 2,
@@ -528,7 +580,12 @@
        return
      }
      if(!this.lat){
        this.wxGetLocation(this.pay)
        if(this.payWay == 2){
          this.wxGetLocation(this.pay)
        }
        if(this.payWay == 5){
          this.apGetLocation(this.pay)
        }
      }else{
        this.pay()
      }
@@ -542,7 +599,7 @@
      this.bordShow = false
      // 金额 this.money
      uni.showLoading()
      const params = {
      let params = {
        money: this.$utils.accMul(this.money,100),
        shopId: this.shopInfo.id,
        payWay: this.payWay,
@@ -558,6 +615,9 @@
      if (this.cid) {
        params.cid = this.cid
      }
      if (this.orderId) {
        params = {onlineId: this.onlineId}
      }
      //生成订单
      saveOrder(params).then(res => {
        uni.hideLoading()