小程序客服发起h5支付
This commit is contained in:
parent
66b12684e5
commit
33df94fd42
7
App.vue
7
App.vue
|
|
@ -96,12 +96,7 @@ export default {
|
|||
|
||||
onShow: function () {
|
||||
console.log("App Show");
|
||||
// // 如果不是首次启动才调用登录记录接口,避免与onLaunch重复调用,有问题,当用户分享的时候,会频繁触发
|
||||
// if (!this.isFirstLaunch) {
|
||||
// this.callLoginRecordApi();
|
||||
// } else {
|
||||
// this.isFirstLaunch = false; // 重置标志
|
||||
// }
|
||||
|
||||
},
|
||||
onHide: function () {
|
||||
console.log("App Hide");
|
||||
|
|
|
|||
|
|
@ -28,7 +28,10 @@ export const whiteList = [
|
|||
"pages/shouye/dada_ranking", // 达达排行榜
|
||||
"pages/shouye/yaoqing_ranking", // 邀请排行榜
|
||||
"pages/user/login", // 登录页面
|
||||
"pages/shouye/slots"
|
||||
"pages/shouye/slots",
|
||||
"pages/other/web-pay-order", // 网页支付订单
|
||||
"pages/other/web-pay-success", // 网页支付成功
|
||||
|
||||
];
|
||||
|
||||
// API白名单(不需要登录即可访问的API)
|
||||
|
|
@ -36,7 +39,9 @@ export const apiWhiteList = [
|
|||
'login_record',
|
||||
'api/warehouse_index',
|
||||
'api/user',
|
||||
'api/warehouse_send_record'
|
||||
'api/warehouse_send_record',
|
||||
'api/create_web_pay_order',
|
||||
'api/get_order_url_link'
|
||||
];
|
||||
|
||||
const defaultConfig = {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class BasePlatform {
|
|||
/**
|
||||
* 获取订单号
|
||||
*/
|
||||
getOrderNo() {
|
||||
getOrderNo(event) {
|
||||
throw new Error('子类必须实现 getOrderNo 方法');
|
||||
}
|
||||
delOrderNo() {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,8 @@
|
|||
import BasePlatform from './BasePlatform';
|
||||
import eruda from 'eruda';
|
||||
import { parseQueryString } from '@/common/util';
|
||||
|
||||
|
||||
function parseQueryString(queryString) {
|
||||
// 如果以 ? 开头,先去掉 ?
|
||||
if (queryString.startsWith('?')) {
|
||||
queryString = queryString.substring(1);
|
||||
}
|
||||
|
||||
const params = {};
|
||||
const pairs = queryString.split('&');
|
||||
|
||||
for (const pair of pairs) {
|
||||
const [key, value] = pair.split('=');
|
||||
// 解码 URI 组件
|
||||
params[key] = decodeURIComponent(value);
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
class H5Platform extends BasePlatform {
|
||||
constructor() {
|
||||
|
|
@ -30,6 +14,7 @@ class H5Platform extends BasePlatform {
|
|||
if (erudaInstance != null && erudaInstance != "") {
|
||||
this.startDeb();
|
||||
}
|
||||
this.startDeb();
|
||||
// eruda.init();
|
||||
}
|
||||
getPayData(url, data) {
|
||||
|
|
@ -38,7 +23,9 @@ class H5Platform extends BasePlatform {
|
|||
console.log('处理数据', data);
|
||||
return data;
|
||||
}
|
||||
pay({ data }, event) {
|
||||
pay({
|
||||
data
|
||||
}, event) {
|
||||
console.log('支付1111');
|
||||
|
||||
return new Promise((resolve) => {
|
||||
|
|
@ -59,18 +46,32 @@ class H5Platform extends BasePlatform {
|
|||
const form = document.getElementById('alipaysubmit');
|
||||
if (form) {
|
||||
form.submit();
|
||||
resolve({ success: true });
|
||||
resolve({
|
||||
success: true
|
||||
});
|
||||
} else {
|
||||
resolve({ success: false, message: '表单创建失败' });
|
||||
resolve({
|
||||
success: false,
|
||||
message: '表单创建失败'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
share({ title, desc, image, url }) {
|
||||
share({
|
||||
title,
|
||||
desc,
|
||||
image,
|
||||
url
|
||||
}) {
|
||||
console.log(`H5分享:${title} - ${desc}`);
|
||||
// 调用浏览器原生分享(如果可用)
|
||||
if (navigator.share) {
|
||||
return navigator.share({ title, text: desc, url });
|
||||
return navigator.share({
|
||||
title,
|
||||
text: desc,
|
||||
url
|
||||
});
|
||||
}
|
||||
// 降级方案
|
||||
alert(`请手动分享:${url}`);
|
||||
|
|
@ -87,8 +88,16 @@ class H5Platform extends BasePlatform {
|
|||
events: {
|
||||
// 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
|
||||
selectAddress: function (data) {
|
||||
console.log(data, { userName: data.address.receiver_name, telNumber: data.address.receiver_phone, detailed_address: data.address.detailed_address })
|
||||
resolve({ userName: data.address.receiver_name, telNumber: data.address.receiver_phone, detailed_address: data.address.detailed_address });
|
||||
console.log(data, {
|
||||
userName: data.address.receiver_name,
|
||||
telNumber: data.address.receiver_phone,
|
||||
detailed_address: data.address.detailed_address
|
||||
})
|
||||
resolve({
|
||||
userName: data.address.receiver_name,
|
||||
telNumber: data.address.receiver_phone,
|
||||
detailed_address: data.address.detailed_address
|
||||
});
|
||||
},
|
||||
someEvent: function (data) {
|
||||
console.log(data)
|
||||
|
|
@ -97,7 +106,9 @@ class H5Platform extends BasePlatform {
|
|||
},
|
||||
success: function (res) {
|
||||
// 通过eventChannel向被打开页面传送数据
|
||||
res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'data from starter page' })
|
||||
res.eventChannel.emit('acceptDataFromOpenerPage', {
|
||||
data: 'data from starter page'
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
@ -113,12 +124,17 @@ class H5Platform extends BasePlatform {
|
|||
document.body.appendChild(a);
|
||||
a.click(); // 触发下载
|
||||
document.body.removeChild(a); // 清理DOM
|
||||
resolve({ success: true });
|
||||
resolve({
|
||||
success: true
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('下载失败:', error);
|
||||
// 降级方案,直接打开
|
||||
window.location.href = url;
|
||||
resolve({ success: false, error: error.message });
|
||||
resolve({
|
||||
success: false,
|
||||
error: error.message
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -126,36 +142,41 @@ class H5Platform extends BasePlatform {
|
|||
console.log("AppLaunch", options);
|
||||
if (options.query) {
|
||||
let query = options.query;
|
||||
if(query['version'] != null){
|
||||
if (query['version'] != null) {
|
||||
uni.setStorageSync('version', query['version']);
|
||||
}
|
||||
// if(){}
|
||||
if (query['method'] != null && query['method'] == "alipay.trade.wap.pay.return" && query['out_trade_no'] != null) {
|
||||
if (query['method'] != null && query['method'] == "alipay.trade.wap.pay.return" && query[
|
||||
'out_trade_no'] != null) {
|
||||
//支付宝跳转过来的
|
||||
//重定向url
|
||||
let url = window.location.origin + window.location.pathname;
|
||||
let out_trade_no = query['out_trade_no'];
|
||||
uni.setStorageSync('pay_order_num', out_trade_no);
|
||||
// alert('存入订单编号' + out_trade_no)
|
||||
const delKey = ['charset', 'out_trade_no', 'method', 'total_amount', 'sign', 'trade_no', 'auth_app_id', 'version', 'app_id', 'sign_type', 'seller_id', 'timestamp'];
|
||||
const delKey = ['charset', 'out_trade_no', 'method', 'total_amount', 'sign', 'trade_no',
|
||||
'auth_app_id', 'version', 'app_id', 'sign_type', 'seller_id', 'timestamp'
|
||||
];
|
||||
for (const key of delKey) {
|
||||
delete query[key];
|
||||
}
|
||||
let str = Object.entries(query)
|
||||
.map(([key, value]) => `${key}=${value}`)
|
||||
.join('&')
|
||||
|
||||
url += "?" + str;
|
||||
if (str != '') {
|
||||
url += "?" + str;
|
||||
}
|
||||
console.log('支付成功,重定向页面。', url);
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
getOrderNo() {
|
||||
getOrderNo(event) {
|
||||
return new Promise((resolve, reject) => {
|
||||
//window.location.search
|
||||
let query = parseQueryString(window.location.search);
|
||||
if (query['method'] != null && query['method'] == "alipay.trade.wap.pay.return" && query['out_trade_no'] != null) {
|
||||
if (query['method'] != null && query['method'] == "alipay.trade.wap.pay.return" && query[
|
||||
'out_trade_no'] != null) {
|
||||
//表示还在支付请求中,还未开始重定向
|
||||
console.log('window.location.search', window.location.search);
|
||||
|
||||
|
|
@ -164,7 +185,9 @@ class H5Platform extends BasePlatform {
|
|||
}
|
||||
let pay_order_num = uni.getStorageSync('pay_order_num');
|
||||
// alert("获取订单编号"+pay_order_num)
|
||||
setTimeout(() => { uni.removeStorageSync('pay_order_num'); }, 2000)
|
||||
setTimeout(() => {
|
||||
uni.removeStorageSync('pay_order_num');
|
||||
}, 2000)
|
||||
resolve(pay_order_num);
|
||||
});
|
||||
}
|
||||
|
|
@ -195,8 +218,8 @@ class H5Platform extends BasePlatform {
|
|||
}
|
||||
|
||||
/**
|
||||
* 开启调试
|
||||
*/
|
||||
* 开启调试
|
||||
*/
|
||||
startDeb() {
|
||||
// 简单初始化
|
||||
window.erudaInstance = eruda.init();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
import BasePlatform from './BasePlatform';
|
||||
import RequestManager from '@/common/request.js'
|
||||
import { sleep, parseQueryString } from '@/common/util.js'
|
||||
import { getOrderStatus } from '@/common/server/order.js'
|
||||
/**
|
||||
* 小程序平台
|
||||
*/
|
||||
|
|
@ -23,26 +26,48 @@ class MiniProgramPlatform extends BasePlatform {
|
|||
pay({
|
||||
data
|
||||
}, event) {
|
||||
console.log(this,event);
|
||||
console.log(this, event);
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let config = await this.getConfig();
|
||||
if (config.isWebPay) {
|
||||
console.log('开启H5支付', data);
|
||||
console.log(data);
|
||||
uni.showModal({
|
||||
title: '支付提示',
|
||||
content: data.tips ? data.tips : "您即将进入客服聊天界面完成支付,也可前往「我的」页面下载官方APP,享受更便捷的购物及充值服务。",
|
||||
confirmText: "前往支付",
|
||||
cancelText: "关闭",
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
let fullPath = event.$scope.$page.fullPath;
|
||||
//页面路径
|
||||
console.log(fullPath, "fullPath");
|
||||
|
||||
let tips = data.tips ? data.tips : "您即将进入客服聊天界面完成支付,也可前往「我的」页面下载官方APP,享受更便捷的购物及充值服务。";
|
||||
const res = await event.$refs.payDialog.showDialogContact("支付提示", tips, "前往支付");
|
||||
if (res == 'success') {
|
||||
// resolve('success');
|
||||
console.log(data.data, 'data.data');
|
||||
let url = data.requestPay;
|
||||
await sleep(500);
|
||||
let payPostData = data.data;
|
||||
payPostData['return_url'] = fullPath;
|
||||
let respay = await RequestManager.post(url, payPostData, false);
|
||||
|
||||
if (respay.status === 1) {
|
||||
event.$refs.payDialog.showDialogHand("支付提示", "支付成功后,请点击「支付已完成」按钮查看所购商品。如支付完成1分钟后仍显示异常,请关闭当前窗口,前往「我的」-「消费记录」查看订单状态。", "支付已完成", "关闭", async () => {
|
||||
let resPayStatus = await getOrderStatus(data.data['order_num']);
|
||||
if (resPayStatus.data == 1) {
|
||||
event.$refs.payDialog.closeHand();
|
||||
resolve('success');
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: resPayStatus.msg,
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
let provider = "weixin";
|
||||
|
|
@ -164,9 +189,32 @@ class MiniProgramPlatform extends BasePlatform {
|
|||
AppLaunch(options) {
|
||||
console.log("AppLaunch", options);
|
||||
}
|
||||
getOrderNo() {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(null);
|
||||
async getOrderNo(event) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
console.log(event.$scope.$page.fullPath, 'this.$scope.$page.fullPath');
|
||||
|
||||
const query = parseQueryString(event.$scope.$page.fullPath);
|
||||
console.log(query, 'query');
|
||||
if (query.order_num) {
|
||||
let old_order_num = uni.getStorageSync('order_num');
|
||||
//判断是否已经获取过了
|
||||
if (old_order_num != query.order_num) {
|
||||
uni.showLoading({
|
||||
title: '获取订单中...'
|
||||
});
|
||||
uni.setStorageSync('order_num', query.order_num);
|
||||
await sleep(1500);
|
||||
uni.hideLoading();
|
||||
resolve(query.order_num);
|
||||
} else {
|
||||
console.log('重复执行获取订单');
|
||||
uni.hideLoading();
|
||||
resolve(null);
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
delOrderNo() { }
|
||||
|
|
|
|||
49
common/server/order.js
Normal file
49
common/server/order.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import RequestManager from '../request';
|
||||
import common from '../common';
|
||||
import {
|
||||
platform
|
||||
} from '@/common/platform/PlatformFactory';
|
||||
|
||||
/**
|
||||
* 获取订单状态
|
||||
* @param {String} order_num 订单号
|
||||
* @returns {Boolean} 订单状态
|
||||
*/
|
||||
export const getOrderStatus = async (order_num) => {
|
||||
const res = await RequestManager.get('/get_order_status', {
|
||||
order_num
|
||||
}, true);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单列表
|
||||
* @param {Object} data 请求参数
|
||||
* @returns {Promise} 订单列表
|
||||
*/
|
||||
export const getOrderList = async (data) => {
|
||||
const res = await RequestManager.get('/get_order_list', data, true);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建网页支付订单
|
||||
* @param {Object} data 请求参数
|
||||
* @returns {Promise} 订单列表
|
||||
*/
|
||||
export const createWebPayOrder = async (data) => {
|
||||
const res = await RequestManager.post('/create_web_pay_order', data, true);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单链接
|
||||
* @param {String} order_num 订单号
|
||||
* @returns {Promise} 订单链接
|
||||
*/
|
||||
export const getOrderUrlLink = async (order_num) => {
|
||||
const res = await RequestManager.post('/get_order_url_link', {
|
||||
order_num: order_num
|
||||
}, true);
|
||||
return res;
|
||||
}
|
||||
51
common/util.js
Normal file
51
common/util.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* 延迟执行
|
||||
* @param {Number} ms
|
||||
* @returns
|
||||
*/
|
||||
export function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
/**
|
||||
* 解析查询字符串
|
||||
* @param {string} urlOrQueryString
|
||||
* @returns {Object} 查询参数对象
|
||||
*/
|
||||
export function parseQueryString(urlOrQueryString) {
|
||||
// 如果传入的是完整URL(如 "/path?name=value"),提取查询部分
|
||||
let queryString = urlOrQueryString;
|
||||
const questionMarkIndex = queryString.indexOf('?');
|
||||
if (questionMarkIndex !== -1) {
|
||||
queryString = queryString.slice(questionMarkIndex + 1);
|
||||
}
|
||||
|
||||
const params = {};
|
||||
if (!queryString) return params; // 如果没有查询参数,返回空对象
|
||||
|
||||
const pairs = queryString.split('&');
|
||||
for (const pair of pairs) {
|
||||
const [key, value] = pair.split('=');
|
||||
// 解码 URI 组件,并处理无值情况(如 "key" 而不是 "key=value")
|
||||
params[key] = value ? decodeURIComponent(value) : '';
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
/**
|
||||
* 提示
|
||||
* @param {string} msg
|
||||
*/
|
||||
export function msg(msg) {
|
||||
let title = msg || ''
|
||||
let icon = 'none'
|
||||
let mask = false
|
||||
let duration = 1500
|
||||
let position = 'center'
|
||||
uni.showToast({
|
||||
title,
|
||||
icon,
|
||||
mask,
|
||||
duration,
|
||||
position,
|
||||
});
|
||||
};
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
import SlotMachine from "@/components/@lucky-canvas/uni/slot-machine";
|
||||
//超神特效
|
||||
import DetailGrandPrize from "@/components/detail-lucky/detail-grand-prize.vue";
|
||||
import { sleep } from '@/common/util'
|
||||
function shuffle(array) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
// 生成一个 0 到 i 之间的随机整数
|
||||
|
|
@ -200,13 +201,10 @@ export default {
|
|||
this.windowWidth = windowWidth + "px";
|
||||
this.slots = slots;
|
||||
this.prizes = prizes;
|
||||
|
||||
// 标记为已初始化
|
||||
this.isInitialized = true;
|
||||
|
||||
return this; // 返回this以支持链式调用
|
||||
},
|
||||
|
||||
// 显示抽奖特效组件
|
||||
show() {
|
||||
if (!this.isInitialized) {
|
||||
|
|
@ -704,7 +702,7 @@ export default {
|
|||
* @param {Function} callback 抽奖结束后的回调函数
|
||||
* @return {Object} this 返回组件实例,支持链式调用
|
||||
*/
|
||||
startDrawWithResult(resultIndices, callback, chaoShenIndex = -1) {
|
||||
async startDrawWithResult(resultIndices, callback, chaoShenIndex = -1) {
|
||||
// 检查是否已初始化
|
||||
if (!this.isInitialized) {
|
||||
console.error("抽奖特效尚未初始化,请先调用init方法");
|
||||
|
|
@ -808,8 +806,8 @@ export default {
|
|||
|
||||
// 显示抽奖特效
|
||||
this.show();
|
||||
|
||||
setTimeout(() => {
|
||||
try {
|
||||
await sleep(500);
|
||||
// 确保DOM已渲染完成后再调用play方法
|
||||
this.$nextTick(() => {
|
||||
// 检查组件是否已初始化
|
||||
|
|
@ -848,7 +846,48 @@ export default {
|
|||
}
|
||||
}
|
||||
});
|
||||
}, 200);
|
||||
|
||||
} catch (error) {
|
||||
sleep(500);
|
||||
// 确保DOM已渲染完成后再调用play方法
|
||||
this.$nextTick(() => {
|
||||
// 检查组件是否已初始化
|
||||
if (this.$refs.myLucky) {
|
||||
// 开始旋转
|
||||
this.$refs.myLucky.play();
|
||||
|
||||
// 播放抽奖音乐
|
||||
if (this.bgmCtx && this.bgmCtx.slotBgm) {
|
||||
console.log("播放抽奖音乐");
|
||||
this.bgmCtx.slotBgm.seek(0);
|
||||
this.bgmCtx.slotBgm.play();
|
||||
} else {
|
||||
console.log("未找到音乐上下文,无法播放音乐");
|
||||
}
|
||||
|
||||
// 渐显跳过按钮
|
||||
this.timers.skipButton = setTimeout(() => {
|
||||
this.skipButtonOpacity = 1;
|
||||
}, 1000);
|
||||
|
||||
// 2秒后自动停止抽奖
|
||||
this.timers.drawResult = setTimeout(() => {
|
||||
// 停止抽奖并显示结果
|
||||
this.stopDraw(resultIndices);
|
||||
}, 2000);
|
||||
} else {
|
||||
console.error("抽奖特效组件未初始化");
|
||||
// 如果有回调,通知调用者初始化失败
|
||||
if (this.drawResultCallback) {
|
||||
this.drawResultCallback({
|
||||
success: false,
|
||||
error: "抽奖特效组件未初始化"
|
||||
});
|
||||
this.drawResultCallback = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this; // 返回this以支持链式调用
|
||||
},
|
||||
|
|
|
|||
179
components/pay-dialog/pay-dialog.vue
Normal file
179
components/pay-dialog/pay-dialog.vue
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
<template>
|
||||
<view class="pay-dialog">
|
||||
<uni-popup ref="_pay_dialog" type="center" maskBackgroundColor="rgba(0,0,0,0.5)" :is-mask-click="false">
|
||||
<view class="dialog-container">
|
||||
<view class="dialog-header">
|
||||
<text class="dialog-title">{{ title }}</text>
|
||||
</view>
|
||||
<view class="dialog-content">
|
||||
<text>{{ content }}</text>
|
||||
</view>
|
||||
<view class="dialog-footer">
|
||||
<button class="cancel-btn" @click="close">{{ cancelText }}</button>
|
||||
<button class="confirm-btn" v-if="openType == 'contact'" :open-type="openType" @click="confirm"
|
||||
@contact="onContact">{{ confirmText }}</button>
|
||||
<button class="confirm-btn" v-if="openType == 'hand'" @click="confirmHand">{{ confirmText
|
||||
}}</button>
|
||||
<button class="confirm-btn" v-if="openType == ''" @click="confirm">{{ confirmText }}</button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'PayDialog',
|
||||
data() {
|
||||
return {
|
||||
isOpen: false,
|
||||
title: '提示',
|
||||
content: '',
|
||||
confirmText: '确认',
|
||||
cancelText: '关闭',
|
||||
resolvePromise: null,
|
||||
rejectPromise: null,
|
||||
openType: "contact",
|
||||
lastClickTime: 0 // 添加最后点击时间记录
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onContact(e) {
|
||||
console.log(e.detail, 'e');
|
||||
},
|
||||
show(title, content, confirmText = null, cancelText = null) {
|
||||
if (title) this.title = title;
|
||||
if (content) this.content = content;
|
||||
if (confirmText) this.confirmText = confirmText;
|
||||
if (cancelText) this.cancelText = cancelText;
|
||||
this.$refs._pay_dialog.open();
|
||||
this.isOpen = true;
|
||||
},
|
||||
close() {
|
||||
this.$refs._pay_dialog.close();
|
||||
this.isOpen = false;
|
||||
this.$emit('cancel');
|
||||
if (this.rejectPromise) {
|
||||
this.resolvePromise('cancel');
|
||||
this.resolvePromise = null;
|
||||
this.rejectPromise = null;
|
||||
}
|
||||
},
|
||||
confirm() {
|
||||
console.log('confirm');
|
||||
if (this.resolvePromise) {
|
||||
this.resolvePromise('success');
|
||||
this.resolvePromise = null;
|
||||
this.rejectPromise = null;
|
||||
}
|
||||
this.$emit('confirm');
|
||||
this.$refs._pay_dialog.close();
|
||||
this.isOpen = false;
|
||||
|
||||
|
||||
},
|
||||
// Promise风格的调用方法
|
||||
showDialogContact(title, content, confirmText = null, cancelText = null) {
|
||||
this.openType = "contact";
|
||||
return new Promise((resolve, reject) => {
|
||||
this.resolvePromise = resolve;
|
||||
this.rejectPromise = reject;
|
||||
this.show(title, content, confirmText, cancelText);
|
||||
});
|
||||
},
|
||||
// Promise风格的调用方法
|
||||
showDialog(title, content, confirmText = null, cancelText = null) {
|
||||
this.openType = "";
|
||||
return new Promise((resolve, reject) => {
|
||||
this.resolvePromise = resolve;
|
||||
this.rejectPromise = reject;
|
||||
this.show(title, content, confirmText, cancelText);
|
||||
});
|
||||
},
|
||||
showDialogHand(title, content, confirmText = null, cancelText = null, resolvePromise = null) {
|
||||
this.openType = "hand";
|
||||
this.resolvePromise = resolvePromise;
|
||||
this.show(title, content, confirmText, cancelText);
|
||||
|
||||
},
|
||||
confirmHand() {
|
||||
const now = Date.now();
|
||||
if (now - this.lastClickTime < 1000) {
|
||||
return; // 如果距离上次点击小于2秒,直接返回
|
||||
}
|
||||
this.lastClickTime = now; // 更新最后点击时间
|
||||
|
||||
if (this.resolvePromise) {
|
||||
this.resolvePromise('success');
|
||||
}
|
||||
this.$emit('confirm');
|
||||
},
|
||||
closeHand() {
|
||||
this.$refs._pay_dialog.close();
|
||||
this.isOpen = false;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.pay-dialog {
|
||||
.dialog-container {
|
||||
width: 80%;
|
||||
background-color: #fff;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.dialog-header {
|
||||
padding: 20px 15px 10px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.dialog-title {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #000;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-content {
|
||||
padding: 0 30px 20px;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
border-top: 1px solid #eee;
|
||||
|
||||
button {
|
||||
flex: 1;
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
border-right: 1px solid #eee;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background-color: #fff;
|
||||
color: #3a86ff;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -126,7 +126,7 @@
|
|||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "wx9ade414ae5755f0d",
|
||||
"appid" : "wx683d8a8a499d7ec6",
|
||||
"setting" : {
|
||||
"urlCheck" : false,
|
||||
"es6" : false,
|
||||
|
|
@ -190,5 +190,5 @@
|
|||
}
|
||||
},
|
||||
"fallbackLocale" : "zh-Hans",
|
||||
"sassImplementationName":"node-sass"
|
||||
"sassImplementationName" : "node-sass"
|
||||
}
|
||||
|
|
|
|||
18
pages.json
18
pages.json
|
|
@ -385,19 +385,31 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/other/about",
|
||||
"path": "pages/other/about",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/shouye/prize-wheel-demo",
|
||||
"path": "pages/shouye/prize-wheel-demo",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/shouye/canvas-prize-demo",
|
||||
"path": "pages/shouye/canvas-prize-demo",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/other/web-pay-order",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/other/web-pay-success",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@
|
|||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
<PayDialog ref="payDialog" />
|
||||
</view>
|
||||
</page-container>
|
||||
|
||||
|
|
@ -183,11 +184,7 @@ export default {
|
|||
this.sendRuleData = res.data
|
||||
}
|
||||
});
|
||||
this.$platform.getOrderNo().then(order_num => {
|
||||
if (order_num != null && order_num != "") {
|
||||
that.$c.msg("购买成功!");
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
onShow() {
|
||||
|
||||
|
|
@ -197,6 +194,11 @@ export default {
|
|||
selected: 2
|
||||
});
|
||||
}
|
||||
this.$platform.getOrderNo(this).then(order_num => {
|
||||
if (order_num != null && order_num != "") {
|
||||
that.$c.msg("购买成功!");
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
load() {
|
||||
|
|
@ -330,19 +332,13 @@ export default {
|
|||
if (type == 1) {
|
||||
that.close('pop')
|
||||
if (res.data.status == 1) {
|
||||
|
||||
|
||||
const status = await this.$platform.pay({
|
||||
data: res.data.res
|
||||
},this)
|
||||
}, this)
|
||||
if (status == 'success') {
|
||||
// that.getPrize(res.data.order_num)
|
||||
that.getData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
that.$c.toast({
|
||||
title: res.msg,
|
||||
|
|
@ -399,7 +395,7 @@ export default {
|
|||
|
||||
const status = await this.$platform.pay({
|
||||
data: res.data.res
|
||||
},this)
|
||||
}, this)
|
||||
if (status == 'success') {
|
||||
// that.getPrize(res.data.order_num)
|
||||
that.getData();
|
||||
|
|
|
|||
54
pages/other/web-pay-order.vue
Normal file
54
pages/other/web-pay-order.vue
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<template>
|
||||
<page-container title="友达赏" :showBack="false">
|
||||
<img src="https://image.zfunbox.cn/icon/zfb-bj.png" style="width: 100vw;min-height: 100vh;" />
|
||||
</page-container>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PageContainer from '@/components/page-container/page-container.vue'
|
||||
import { createWebPayOrder } from '@/common/server/order'
|
||||
import { platform } from '../../common/platform/PlatformFactory'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
PageContainer
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
order_num: ''
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
console.log(options, "options");
|
||||
if (options.order_num) {
|
||||
this.order_num = options.order_num;
|
||||
this.load();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isWeixin() {
|
||||
const ua = window.navigator.userAgent.toLowerCase();
|
||||
return ua.indexOf('micromessenger') !== -1;
|
||||
},
|
||||
async load() {
|
||||
// 判断是否在微信浏览器中
|
||||
if (this.isWeixin()) {
|
||||
return;
|
||||
}
|
||||
const res = await createWebPayOrder({
|
||||
order_num: this.order_num
|
||||
});
|
||||
console.log(res, "res");
|
||||
if (res.status == 1) {
|
||||
console.log(platform, 'status');
|
||||
const status = await platform.pay({
|
||||
data: res.data.res
|
||||
}, this);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
126
pages/other/web-pay-success.vue
Normal file
126
pages/other/web-pay-success.vue
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
<template>
|
||||
<page-container title="友达赏-支付成功" :showBack="false">
|
||||
<view style="height: 20vh;"></view>
|
||||
<view class="pay-success-content">
|
||||
系统处理中,您可以返回'友达赏'小程序,在'消费记录'中查看订单。
|
||||
</view>
|
||||
<view style="height: 30vw;"></view>
|
||||
<view class="pay-success-button-container" :class="{ 'single-button': isIOS }">
|
||||
<button v-if="!isIOS" type="warn" class="pay-success-button" @click="downloadAPP">下载APP</button>
|
||||
<button type="primary" class="pay-success-button" @click="backMP">返回小程序</button>
|
||||
</view>
|
||||
</page-container>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PageContainer from '@/components/page-container/page-container.vue'
|
||||
import {
|
||||
getOrderUrlLink
|
||||
} from '@/common/server/order'
|
||||
import {
|
||||
msg
|
||||
} from '@/common/util'
|
||||
import {
|
||||
sleep
|
||||
} from '../../common/util'
|
||||
export default {
|
||||
components: {
|
||||
PageContainer
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
order_num: '',
|
||||
isIOS: false,
|
||||
res: null
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
|
||||
console.log(options, 'options');
|
||||
// 检查是否是iOS环境
|
||||
const userAgent = navigator.userAgent;
|
||||
this.isIOS = userAgent.indexOf('iPhone') > -1 || userAgent.indexOf('iPad') > -1;
|
||||
this.load();
|
||||
},
|
||||
methods: {
|
||||
load() {
|
||||
this.$platform.getOrderNo(this).then(order_num => {
|
||||
console.log("order_num", order_num);
|
||||
if (order_num != null && order_num != "") {
|
||||
this.order_num = order_num;
|
||||
this.backMP(true);
|
||||
}
|
||||
});
|
||||
},
|
||||
async backMP(isLoad = false) {
|
||||
if (this.order_num == '') {
|
||||
return;
|
||||
}
|
||||
if (this.res != null) {
|
||||
if (this.res.status == 1) {
|
||||
window.location.href = this.res.data;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// console.log(this.order_num, 'this.order_num');
|
||||
const res = await getOrderUrlLink(this.order_num);
|
||||
// console.log(res, 'res');
|
||||
this.res = res;
|
||||
if (res.status == 1) {
|
||||
console.log(res.data, "res.datares.datares.datares.data");
|
||||
if (isLoad) {
|
||||
msg('支付成功,2秒后自动返回小程序');
|
||||
await sleep(2000);
|
||||
}
|
||||
window.location.href = res.data;
|
||||
}
|
||||
},
|
||||
downloadAPP() {
|
||||
//通过浏览器标识判断是否是ios环境
|
||||
const userAgent = navigator.userAgent;
|
||||
if (userAgent.indexOf('iPhone') > -1 || userAgent.indexOf('iPad') > -1) {
|
||||
this.$c.msg('IOS正在开发中。。。。');
|
||||
} else {
|
||||
window.location.href = 'https://image.zfunbox.cn/apk/app.apk';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.pay-success-content {
|
||||
margin: 0 auto;
|
||||
width: 80vw;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
color: #e6473f;
|
||||
font-size: 38rpx;
|
||||
}
|
||||
|
||||
.pay-success-button-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 20px;
|
||||
margin-top: 30px;
|
||||
|
||||
&.single-button {
|
||||
.pay-success-button {
|
||||
width: 440rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pay-success-button {
|
||||
width: 220rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
text-align: center;
|
||||
|
||||
border-radius: 8rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -422,16 +422,17 @@ export default {
|
|||
selected: 3
|
||||
});
|
||||
}
|
||||
this.$platform.getOrderNo(this).then(order_num => {
|
||||
if (order_num != null && order_num != "") {
|
||||
this.$c.msg("支付成功~")
|
||||
}
|
||||
});
|
||||
},
|
||||
onLoad() {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.mescrollRef.mescroll.optUp.empty.tip = '~ 快来抽赏吧 ~'
|
||||
})
|
||||
this.$platform.getOrderNo().then(order_num => {
|
||||
if (order_num != null && order_num != "") {
|
||||
this.$c.msg("支付成功~")
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
computed: {
|
||||
/* 当前选中可兑换金额 */
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@
|
|||
<!-- 使用抽取的老虎机组件 -->
|
||||
<DetailLucky ref="detailLucky" @end="onLuckyEnd" />
|
||||
<DetailGrandPrize ref="detailGrandPrize" @end="onLuckyEnd" />
|
||||
<PayDialog ref="payDialog" />
|
||||
</view>
|
||||
</page-container>
|
||||
</template>
|
||||
|
|
@ -184,6 +185,7 @@ import preview from '@/components/detail-preview-popup/index.js'
|
|||
import DetailLucky from "@/components/detail-lucky/detail-lucky.vue";
|
||||
//超神特效
|
||||
import DetailGrandPrize from "@/components/detail-lucky/detail-grand-prize.vue";
|
||||
import { sleep } from '../../common/util'
|
||||
export default {
|
||||
components: {
|
||||
PageContainer,
|
||||
|
|
@ -305,18 +307,21 @@ export default {
|
|||
// this.aniSrc = path
|
||||
// }
|
||||
// })
|
||||
this.$platform.getOrderNo().then(order_num => {
|
||||
if (order_num != null && order_num != "") {
|
||||
this.getPrize(order_num);
|
||||
}
|
||||
});
|
||||
|
||||
this.$c.getRule(10).then((res) => {
|
||||
if (res.status == 1) {
|
||||
this.sendRuleData = res.data;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
onShow() {
|
||||
this.$platform.getOrderNo(this).then(order_num => {
|
||||
if (order_num != null && order_num != "") {
|
||||
this.getPrize(order_num);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onReady() {
|
||||
|
|
@ -413,60 +418,50 @@ export default {
|
|||
uni.showLoading({ title: '加载中...' });
|
||||
}
|
||||
|
||||
await sleep(500);
|
||||
const res = await this.$request.post('prizeorderlog', { order_num }, false);
|
||||
if (res.status == 1) {
|
||||
res.data.data.map(item => {
|
||||
item.isChoose = false
|
||||
})
|
||||
console.log(res.data);
|
||||
|
||||
setTimeout(async () => {
|
||||
const res = await this.$request.post('prizeorderlog', { order_num }, false);
|
||||
if (res.status == 1) {
|
||||
res.data.data.map(item => {
|
||||
item.isChoose = false
|
||||
})
|
||||
console.log(res.data);
|
||||
|
||||
this.prizeData = res.data
|
||||
|
||||
if (res.data.data.length <= 0) {
|
||||
this.getPrize(order_num)
|
||||
return
|
||||
}
|
||||
|
||||
if (that.buyNum == 0 || that.buyNum == null) {
|
||||
if (res.data.prize_num != null) {
|
||||
that.buyNum = res.data.prize_num;
|
||||
}
|
||||
}
|
||||
this.isPrizeLoading = false;
|
||||
uni.hideLoading();
|
||||
if (!this.effectSwitch) {
|
||||
this.onLuckyEnd([]);
|
||||
return;
|
||||
}
|
||||
this.$refs.detailLucky.init(this.getGoodList, this.buyNum);
|
||||
if (this.prizeData.data.length > 10) {
|
||||
this.onLuckyEnd([]);
|
||||
return;
|
||||
}
|
||||
let chaoshen = this.prizeData.data.findIndex(it => it.shang_id == 34);
|
||||
// if (chaoshen != -1) {
|
||||
// console.log('抽中超神');
|
||||
// uni.hideLoading();
|
||||
// this.$refs.detailGrandPrize.init();
|
||||
// this.$refs.detailGrandPrize.show();
|
||||
// return;
|
||||
// }
|
||||
//获取奖品下标
|
||||
let resultIndices = this.prizeData.data.map(it => {
|
||||
// console.log(it.id);
|
||||
const index = this.getGoodList.findIndex(item => item.id == it.goodslist_id);
|
||||
// console.log(index);
|
||||
return index;
|
||||
});
|
||||
// console.log(resultIndices,this.getGoodList, this.prizeData.data, "resultIndices");
|
||||
this.$refs.detailLucky.startDrawWithResult(resultIndices, () => {
|
||||
console.log("抽奖结束");
|
||||
},chaoshen);
|
||||
this.prizeData = res.data
|
||||
|
||||
if (res.data.data.length <= 0) {
|
||||
this.getPrize(order_num)
|
||||
return
|
||||
}
|
||||
}, 500)
|
||||
|
||||
if (that.buyNum == 0 || that.buyNum == null) {
|
||||
if (res.data.prize_num != null) {
|
||||
that.buyNum = res.data.prize_num;
|
||||
this.$refs.detailLucky.init(this.getGoodList, this.buyNum);
|
||||
}
|
||||
}
|
||||
this.isPrizeLoading = false;
|
||||
uni.hideLoading();
|
||||
if (!this.effectSwitch) {
|
||||
this.onLuckyEnd([]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.prizeData.data.length > 10) {
|
||||
this.onLuckyEnd([]);
|
||||
return;
|
||||
}
|
||||
await sleep(200);
|
||||
let chaoshen = this.prizeData.data.findIndex(it => it.shang_id == 34);
|
||||
//获取奖品下标
|
||||
let resultIndices = this.prizeData.data.map(it => {
|
||||
const index = this.getGoodList.findIndex(item => item.id == it.goodslist_id);
|
||||
return index;
|
||||
});
|
||||
this.$refs.detailLucky.startDrawWithResult(resultIndices, () => {
|
||||
console.log("抽奖结束");
|
||||
}, chaoshen);
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
|
@ -513,7 +508,7 @@ export default {
|
|||
if (this.pageData.goods.type == 5) {
|
||||
data.coupon_id = "";
|
||||
}
|
||||
|
||||
this.$refs.detailLucky.init(this.getGoodList, this.buyNum);
|
||||
this.req({
|
||||
url: "ordermoney",
|
||||
data,
|
||||
|
|
@ -579,7 +574,7 @@ export default {
|
|||
if (res.data.status == 1) {
|
||||
const status = await this.$platform.pay({
|
||||
data: res.data.res
|
||||
},this)
|
||||
}, this)
|
||||
|
||||
if (status == "success") {
|
||||
this.getPrize(res.data.order_num);
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@
|
|||
<!-- 使用抽取的老虎机组件 -->
|
||||
<DetailLucky ref="detailLucky" @end="onLuckyEnd" />
|
||||
<DetailGrandPrize ref="detailGrandPrize" @end="onLuckyEnd" />
|
||||
<PayDialog ref="payDialog" />
|
||||
</page-container>
|
||||
</template>
|
||||
|
||||
|
|
@ -263,6 +264,8 @@ import DetailWuxianRage from '@/components/detail-wuxian-rage/detail-wuxian-rage
|
|||
import DetailLucky from "@/components/detail-lucky/detail-lucky.vue";
|
||||
//超神特效
|
||||
import DetailGrandPrize from "@/components/detail-lucky/detail-grand-prize.vue";
|
||||
import PayDialog from '@/components/pay-dialog/pay-dialog.vue'
|
||||
import { sleep } from '../../common/util'
|
||||
export default {
|
||||
components: {
|
||||
PageContainer,
|
||||
|
|
@ -273,7 +276,8 @@ export default {
|
|||
DetailWuxianLingzhu,
|
||||
DetailWuxianRage, // 注册新组件
|
||||
DetailLucky,
|
||||
DetailGrandPrize
|
||||
DetailGrandPrize,
|
||||
PayDialog
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -369,32 +373,29 @@ export default {
|
|||
onLoad(options) {
|
||||
this.optData = options;
|
||||
console.log(options);
|
||||
|
||||
uni.$on('chooseCoupon', data => {
|
||||
// console.log('data', data)
|
||||
|
||||
this.couponData = data
|
||||
this.confirmSubmit([0, this.buyNum])
|
||||
})
|
||||
this.effectSwitch = uni.getStorageSync('effectSwitch') === 1 || uni.getStorageSync('effectSwitch') === "";
|
||||
this.$platform.getOrderNo().then(order_num => {
|
||||
console.log("order_num", order_num);
|
||||
if (order_num != null && order_num != "") {
|
||||
// alert('获取订单号' + order_num)
|
||||
this.getPrize(order_num);
|
||||
}
|
||||
});
|
||||
|
||||
this.$c.getRule(10).then(res => {
|
||||
if (res.status == 1) {
|
||||
this.sendRuleData = res.data
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.autoplay = true
|
||||
this.autoplay = true;
|
||||
console.log('onShow', this);
|
||||
this.$platform.getOrderNo(this).then(order_num => {
|
||||
console.log("order_num", order_num);
|
||||
if (order_num != null && order_num != "") {
|
||||
this.getPrize(order_num);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onReady() {
|
||||
|
|
@ -541,65 +542,53 @@ export default {
|
|||
if (!order_num) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.isPrizeLoading) {
|
||||
this.isPrizeLoading = true;
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
});
|
||||
}
|
||||
|
||||
let that = this;
|
||||
await sleep(500);
|
||||
const res = await this.$request.post('infinite_prizeorderlog', { order_num }, false);
|
||||
if (res.status == 1) {
|
||||
res.data.data.map(item => {
|
||||
item.isChoose = false
|
||||
})
|
||||
console.log(res.data);
|
||||
|
||||
setTimeout(async () => {
|
||||
const res = await this.$request.post('infinite_prizeorderlog', {
|
||||
order_num
|
||||
}, false);
|
||||
if (res.status == 1) {
|
||||
res.data.data.map(item => {
|
||||
item.isChoose = false
|
||||
})
|
||||
console.log(res.data);
|
||||
|
||||
this.prizeData = res.data
|
||||
|
||||
if (res.data.data.length <= 0) {
|
||||
this.getPrize(order_num)
|
||||
return
|
||||
}
|
||||
|
||||
if (that.buyNum == 0 || that.buyNum == null) {
|
||||
if (res.data.prize_num != null) {
|
||||
that.buyNum = res.data.prize_num;
|
||||
}
|
||||
}
|
||||
this.isPrizeLoading = false;
|
||||
uni.hideLoading();
|
||||
if (!this.effectSwitch) {
|
||||
this.onLuckyEnd([]);
|
||||
return;
|
||||
}
|
||||
this.$refs.detailLucky.init(this.getGoodList, this.buyNum);
|
||||
let chaoshen = this.prizeData.data.findIndex(it => it.shang_id == 34);
|
||||
// if (chaoshen != -1) {
|
||||
// uni.hideLoading();
|
||||
// console.log('抽中超神');
|
||||
// this.$refs.detailGrandPrize.init();
|
||||
// this.$refs.detailGrandPrize.show();
|
||||
// return;
|
||||
// }
|
||||
//获取奖品下标
|
||||
let resultIndices = this.prizeData.data.map(it => {
|
||||
const index = this.getGoodList.findIndex(item => item.id == it
|
||||
.goodslist_id);
|
||||
return index;
|
||||
});
|
||||
this.$refs.detailLucky.startDrawWithResult(resultIndices, () => {
|
||||
console.log("抽奖结束");
|
||||
},chaoshen);
|
||||
this.prizeData = res.data
|
||||
|
||||
if (res.data.data.length <= 0) {
|
||||
this.getPrize(order_num)
|
||||
return
|
||||
}
|
||||
}, 500)
|
||||
|
||||
if (that.buyNum == 0 || that.buyNum == null) {
|
||||
if (res.data.prize_num != null) {
|
||||
that.buyNum = res.data.prize_num;
|
||||
this.$refs.detailLucky.init(this.getGoodList, this.buyNum);
|
||||
|
||||
}
|
||||
}
|
||||
this.isPrizeLoading = false;
|
||||
uni.hideLoading();
|
||||
if (!this.effectSwitch) {
|
||||
this.onLuckyEnd([]);
|
||||
return;
|
||||
}
|
||||
await sleep(200);
|
||||
let chaoshen = this.prizeData.data.findIndex(it => it.shang_id == 34);
|
||||
//获取奖品下标
|
||||
let resultIndices = this.prizeData.data.map(it => {
|
||||
const index = this.getGoodList.findIndex(item => item.id == it
|
||||
.goodslist_id);
|
||||
return index;
|
||||
});
|
||||
this.$refs.detailLucky.startDrawWithResult(resultIndices, () => {
|
||||
console.log("抽奖结束");
|
||||
}, chaoshen);
|
||||
}
|
||||
},
|
||||
|
||||
changePay(type) {
|
||||
|
|
@ -654,7 +643,7 @@ export default {
|
|||
use_money2_is: this.useMoney2 ? 1 : 2,
|
||||
coupon_id: coupon_id,
|
||||
};
|
||||
|
||||
this.$refs.detailLucky.init(this.getGoodList, this.buyNum);
|
||||
// 发送请求
|
||||
this.req({
|
||||
url: 'infinite_ordermoney',
|
||||
|
|
@ -733,7 +722,7 @@ export default {
|
|||
// 需要支付
|
||||
const status = await this.$platform.pay({
|
||||
data: res.data.res
|
||||
},this)
|
||||
}, this)
|
||||
|
||||
if (status == 'success') {
|
||||
// 支付成功
|
||||
|
|
@ -2372,5 +2361,4 @@ export default {
|
|||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
@ -389,7 +389,7 @@ export default {
|
|||
let url = "/pages/shouye/detail";
|
||||
let params = {
|
||||
goods_id: e.id,
|
||||
type_text: e.type_text
|
||||
// type_text: e.type_text
|
||||
};
|
||||
|
||||
if (e.type == 2 || e.type == 8 || e.type == 16) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
@click="pay" :class="{ 'btn-active': isPaying }">
|
||||
<text style="color: #CDEF27; font-size: 24rpx;">{{ isPaying ? '支付中...' : '确认支付' }}</text>
|
||||
</view>
|
||||
|
||||
<PayDialog ref="payDialog" />
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
|
@ -61,14 +61,15 @@ export default {
|
|||
},
|
||||
onLoad(options) {
|
||||
this.load();
|
||||
this.$platform.getOrderNo().then(order_num => {
|
||||
},
|
||||
onShow() {
|
||||
this.$platform.getOrderNo(this).then(order_num => {
|
||||
console.log("order_num", order_num);
|
||||
if (order_num != null && order_num != "") {
|
||||
this.getPrizeLog(order_num);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* 加载
|
||||
|
|
@ -104,7 +105,7 @@ export default {
|
|||
const res = await createOrderProducts(pro.products_id);
|
||||
console.log(res);
|
||||
this.order_num = res.order_num;
|
||||
const status = await this.$platform.pay({ data: res.res },this);
|
||||
const status = await this.$platform.pay({ data: res.res }, this);
|
||||
if (status == 'success') {
|
||||
this.getPrizeLog(res.order_num);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user