Commit 26ab06a3 by 程默

f

parent 3c2267d6
{
"description": "项目配置文件。",
"setting": {
"urlCheck": false,
"es6": true,
"enhance": true,
"postcss": true,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": true,
"autoAudits": true,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": true,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"bundle": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false
},
"miniprogramRoot": "dist/wx/",
"compileType": "miniprogram",
"appid": "wx8a509d2f2ac15903",
"projectname": "mayi-mp-shop",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"gamePlugin": {
"current": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": [
{
"id": 0,
"name": "pages/index/main",
"pathName": "pages/index/main",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/login/main",
"pathName": "pages/login/main",
"query": "",
"scene": null
},
{
"id": 2,
"name": "pages/index/main",
"pathName": "pages/index/main",
"query": "scene=pid_6141",
"scene": 1047
}
]
}
}
"description": "项目配置文件。",
"setting": {
"urlCheck": false,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": true,
"autoAudits": true,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": true,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"miniprogramRoot": "dist/wx/",
"compileType": "miniprogram",
"appid": "wx8a509d2f2ac15903",
"projectname": "mayi-mp-shop",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"plugin": {
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": [
{
"id": 0,
"name": "pages/index/main",
"pathName": "pages/index/main",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/login/main",
"pathName": "pages/login/main",
"query": "",
"scene": null
},
{
"id": 2,
"name": "pages/index/main",
"pathName": "pages/index/main",
"query": "scene=pid_6141",
"scene": 1047
}
]
}
}
}
\ No newline at end of file
<template>
<div class="domain">{{message}}</div>
<div class="domain">{{ message }}</div>
</template>
<script>
......@@ -15,46 +15,54 @@ export default {
shopmixid: "",
openId: "",
options: {},
options_orderType:'',
options_orderType: "",
// 购买会员卡新页面
options_isCard:'',
options_isCardTitle:'',
batchNumber : '',
totalMoney : ''
options_isCard: "",
options_isCardTitle: "",
batchNumber: "",
totalMoney: "",
scene: "", //sso
backUrl: "",
};
},
onLoad(options) {
wx.showLoading({
title: "加载中"
title: "加载中",
});
Object.assign(this.$data, this.$options.data()); //mpvue 的混合周期 使用小程序生命周期数据未初始化
console.log("onload//",options);
if(options.batchNumber){
let ordercode = JSON.parse(options.ordercode)
ordercode.orderSn = ''
ordercode.batchNumber = options.batchNumber
this.options = ordercode
this.batchNumber = ordercode.batchNumber
console.log(JSON.parse(options.ordercode).orderSn)
if(JSON.parse(options.ordercode).orderSn){
this.totalMoney = Number(JSON.parse(options.ordercode).orderSn.totalAmount).toFixed(2)
}else{
this.totalMoney = Number(JSON.parse(options.ordercode).totalAmount).toFixed(2)
}
console.log("onload//", options);
if (options.batchNumber) {
let ordercode = JSON.parse(options.ordercode);
ordercode.orderSn = "";
ordercode.batchNumber = options.batchNumber;
this.options = ordercode;
this.batchNumber = ordercode.batchNumber;
console.log(JSON.parse(options.ordercode).orderSn);
if (JSON.parse(options.ordercode).orderSn) {
this.totalMoney = Number(
JSON.parse(options.ordercode).orderSn.totalAmount
).toFixed(2);
} else {
this.totalMoney = Number(
JSON.parse(options.ordercode).totalAmount
).toFixed(2);
}
// }
console.log(this.totalMoney,'totalMoney')
}else{
console.log(this.totalMoney, "totalMoney");
} else {
this.options = JSON.parse(options.ordercode);
options.scene && (this.scene = options.scene);
options.backUrl && (this.backUrl = options.backUrl);
}
this.options_orderType = options.orderType;
this.options_isCard= options.isCard;
this.options_isCardTitle= options.isCardTit;
if(options.sessionid){
try {
wx.setStorageSync('sessionid', options.sessionid)
} catch (e) { }
this.options_isCard = options.isCard;
this.options_isCardTitle = options.isCardTit;
if (options.sessionid) {
try {
wx.setStorageSync("sessionid", options.sessionid);
} catch (e) {}
}
let that = this;
wx.getStorage({
......@@ -67,39 +75,45 @@ export default {
console.log("支付开始", that.options);
that.toPay();
},
fail(err){
console.log('获取err',err)
}
fail(err) {
console.log("获取err", err);
},
});
},
methods: {
toPay() {
wxPay
.to_wx_pay(this.options)
.then(res => {
.then((res) => {
wx.hideLoading();
if (res.data.code == 200) {
let payData = JSON.parse(res.data.data);
console.log('wxPay',res.data)
payData.success = res => {
console.log("wxPay", res.data);
payData.success = (res) => {
console.log("支付成功", res, this.options);
this.message = "支付成功";
const orderSn = this.options.orderSn;
let vm = this
let vm = this;
try {
const subscribeMessageObj = this.$store.state.subscribeMessageObj;
if (subscribeMessageObj && Object.keys(subscribeMessageObj).length > 0) {
const subscribeMessageObj = this.$store.state
.subscribeMessageObj;
if (
subscribeMessageObj &&
Object.keys(subscribeMessageObj).length > 0
) {
// TODO 小程序订阅消息埋点
const tmplIds = [];
for (var key in subscribeMessageObj) {
for (var key in subscribeMessageObj) {
// 送礼订单
if (this.options_orderType == 5 && (key == 'gift_be_expire' || key == 'gift_draw')) {
if (
this.options_orderType == 5 &&
(key == "gift_be_expire" || key == "gift_draw")
) {
tmplIds.push(subscribeMessageObj[key]);
}
// 订单发货
if (key == 'order_shipment') {
if (key == "order_shipment") {
tmplIds.push(subscribeMessageObj[key]);
}
}
......@@ -108,70 +122,76 @@ export default {
wx.requestSubscribeMessage({
tmplIds: tmplIds,
success(res) {
fn(vm)
fn(vm);
console.log("message success response: ", res);
},
fail(res) {
fn(vm)
console.log("message fail response: ", res)
}
})
}else{
fn(vm)
fn(vm);
console.log("message fail response: ", res);
},
});
} else {
fn(vm);
}
}else{
console.log('来这里了')
fn(this)
} else {
console.log("来这里了");
fn(this);
}
} catch (err) {
console.error("subscribeMessage-err", err);
}
function fn(_this){
function fn(_this) {
// _this.message = "支付成功";
if(!_this.options_isCard){
if (!_this.options_isCard) {
let query;
if(_this.batchNumber){
if (_this.batchNumber) {
query = {
orderSn: _this.options.orderSn,
batchNumber : _this.batchNumber,
multiMerchantsFlag : 1,
totalMoney : _this.totalMoney
batchNumber: _this.batchNumber,
multiMerchantsFlag: 1,
totalMoney: _this.totalMoney,
};
}else{
} else {
query = {
orderSn: _this.options.orderSn
orderSn: _this.options.orderSn,
};
}
// sso场景(跳转第三方url)
if (_this.scene == "sso") {
wx.redirectTo({
url: `../wxArticle/main?from=sso&link=${_this.backUrl}`,
});
return;
}
wx.redirectTo({
url: `../index/main?from=wxPay&backpath=/pay/paySuccess&params=${JSON.stringify(
query
)}`
)}`,
});
}else{
let query = {
cardTitle: _this.options_isCardTitle
}
} else {
let query = {
cardTitle: _this.options_isCardTitle,
};
wx.redirectTo({
url: `../index/main?from=wxPay&backpath=/pay/payCardSuccess&params=${JSON.stringify(
query
)}`
)}`,
});
}
}
};
payData.fail = res => {
payData.fail = (res) => {
console.log("支付失败", res, this.options.orderSn);
this.message = "支付失败";
if (res.errMsg='requestPayment:fail cancel') {
if ((res.errMsg = "requestPayment:fail cancel")) {
wxPay.cancelPayment(this.options.orderSn).then(() => {
console.log("取消成功");
});
}
this.toPage();
};
payData.complete = res => {
payData.complete = (res) => {
console.log("支付completa", res, this.options.orderSn);
// if (res.errMsg == "requestPayment:fail cancel") {
// console.log("支付取消", this.options);
......@@ -184,33 +204,47 @@ export default {
wx.showToast({ title: res.data.msg, icon: "none" });
}
})
.catch(err => {
.catch((err) => {
wx.showToast({ title: res.data.msg, icon: "none" });
});
},
toPage() {
console.log('支付失败来这里了',this.batchNumber)
if(this.batchNumber){
console.log(
"支付失败来这里了",
this.batchNumber,
this.scene == "sso",
this.scene
);
if (this.scene == "sso") {
//sso模式(嵌入第三方)
wx.redirectTo({
url: `../wxArticle/main?from=sso&link=${this.backUrl}`,
});
return;
}
if (this.batchNumber) {
let query = {
multiMerchantsFlag : 1
}
multiMerchantsFlag: 1,
};
wx.redirectTo({
url: `../index/main?from=wxPay&backpath=/order/orderList&params=${JSON.stringify(query)}`
url: `../index/main?from=wxPay&backpath=/order/orderList&params=${JSON.stringify(
query
)}`,
});
return
return;
}
let query = {
orderSn: this.options.orderSn,
payList: true,
orderListToorderDetail: true
orderListToorderDetail: true,
};
wx.redirectTo({
url: `../index/main?from=wxPay&backpath=/order/orderDetail&params=${JSON.stringify(
query
)}`
)}`,
});
}
}
},
},
};
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment