|
@@ -1,6 +1,6 @@
|
|
|
// index.ts
|
|
|
|
|
|
-import { api_shopProduct } from "../../api/login";
|
|
|
+import { api_executeOrder, api_queryByParamName, api_shopProduct } from "../../api/login";
|
|
|
import { debounce } from '../../utils/util'
|
|
|
|
|
|
// 获取应用实例
|
|
@@ -19,13 +19,16 @@ Page({
|
|
|
list: [] as any,
|
|
|
isOverSaled: false, // 是否所有商品都没有库存
|
|
|
selected: {} as any,
|
|
|
+ isH5Pay: true, // 是否公众号支付
|
|
|
+ paymentType: null as any, // 支付类型
|
|
|
+ paymentChannel: null as any,
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad() {
|
|
|
- this.onInit()
|
|
|
+ this.queryPayType()
|
|
|
},
|
|
|
/**
|
|
|
* 获取基础信息
|
|
@@ -149,19 +152,92 @@ Page({
|
|
|
if(!that.isLogin()) {
|
|
|
return
|
|
|
}
|
|
|
- let info = JSON.stringify({
|
|
|
- ...that.data.selected
|
|
|
- });
|
|
|
- console.log(that.data.selected, "that.data.selected")
|
|
|
- info = encodeURIComponent(info);
|
|
|
- wx.navigateTo({
|
|
|
- url: `../orders/order-detail?orderInfo=${info}`,
|
|
|
- })
|
|
|
- that.setData({
|
|
|
- popupShow: false
|
|
|
- })
|
|
|
+ if(that.data.isH5Pay) {
|
|
|
+ that.onH5Play(that.data.selected)
|
|
|
+ } else {
|
|
|
+ let info = JSON.stringify({
|
|
|
+ ...that.data.selected
|
|
|
+ });
|
|
|
+ info = encodeURIComponent(info);
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `../orders/order-detail?orderInfo=${info}`,
|
|
|
+ })
|
|
|
+ that.setData({
|
|
|
+ popupShow: false
|
|
|
+ })
|
|
|
+ }
|
|
|
}, 500)()
|
|
|
},
|
|
|
+ async onH5Play(goodsInfo: any) {
|
|
|
+ wx.showLoading({
|
|
|
+ mask: true,
|
|
|
+ title: "加载中...",
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ // const { salePrice, shopId, name, id, orderNo } = goodsInfo
|
|
|
+ // const { data } = await api_executeOrder({
|
|
|
+ // "orderType": "WECHAT_MINI",
|
|
|
+ // "paymentType": this.data.paymentType,
|
|
|
+ // "paymentCashAmount": salePrice,
|
|
|
+ // "paymentCouponAmount": 0,
|
|
|
+ // "shopId": shopId,
|
|
|
+ // "openId": app.globalData.userInfo?.liteOpenid,
|
|
|
+ // "goodsInfos": [{
|
|
|
+ // "goodsId": id,
|
|
|
+ // "goodsNum": 1,
|
|
|
+ // "goodsType": "ACTIVATION_CODE",
|
|
|
+ // "paymentCashAmount": salePrice,
|
|
|
+ // "paymentCouponAmount": 0
|
|
|
+ // }],
|
|
|
+ // "orderName": name,
|
|
|
+ // "orderDesc": name
|
|
|
+ // })
|
|
|
+ // if (data.code === 200) {
|
|
|
+ // const { paymentConfig, paymentType, orderNo } = data.data
|
|
|
+ // 测试h5页面支付流程
|
|
|
+ const params = {
|
|
|
+ // paymentType: paymentType, //'adapay-cooleshow-6560',
|
|
|
+ // pay_channel: 'wx_pub',
|
|
|
+ // wxAppId: paymentConfig.wxAppId, //'wxbde13f59d40cb4f2',
|
|
|
+ // body: paymentConfig.body, //'aaa',
|
|
|
+ // price: paymentConfig.price, // '0.01',
|
|
|
+ // orderNo: paymentConfig.merOrderNo,
|
|
|
+ // userId: paymentConfig.userId
|
|
|
+ }
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../order-webview/order-webview?orderInfo=' + encodeURIComponent(JSON.stringify(params))
|
|
|
+ })
|
|
|
+
|
|
|
+ wx.hideLoading()
|
|
|
+ // } else {
|
|
|
+ // wx.hideLoading()
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '购买失败',
|
|
|
+ // icon: 'none'
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ } catch {
|
|
|
+ wx.hideLoading()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取后台配置的支付方式
|
|
|
+ async queryPayType() {
|
|
|
+ try {
|
|
|
+ // wxlite_payment_service_provider
|
|
|
+ const { data } = await api_queryByParamName({
|
|
|
+ paramName: 'wxlite_payment_service_provider'
|
|
|
+ });
|
|
|
+ if (data.code == 200) {
|
|
|
+ const paramValue = data.data.paramValue ? JSON.parse(data.data.paramValue) : {}
|
|
|
+ this.setData({
|
|
|
+ paymentType: paramValue.vendor,
|
|
|
+ paymentChannel: paramValue.channel
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error, "error");
|
|
|
+ }
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|