123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- const $ = global;
- const orderTexts = [
- '已预约,等待处理',
- '未付款',
- '已付款'
- ]
- new $.Page({
- data: {
- services: [],
- goods: []
- },
- onShow() {
- this.init();
- },
- init() {
- $.request('my/orders', 'GET', {}).then((res) => {
- if (res.data) {
- const services = res.data.others || [];
- const goods = res.data.product_orders || [];
- services.forEach(e => {
- e.orderText = orderTexts[e.status];
- });
- goods.forEach(e => {
- e.orderText = orderTexts[e.status];
- if (e.status == 0) e.orderText = '待付款';
- e.text = '';
- for (let p of e.products) {
- let t = `${p.name}×${p.amount}`;
- e.text += e.text ? (';' + t) : t;
- }
- });
- this.setData({
- services,
- goods
- });
- }
- });
- },
- toPay(e) {
- const _this = this;
- const {
- id,
- type
- } = e.target.dataset;
- if (id && type) {
- $.wx.showToast({
- title: '支付中'
- }, 'loading');
- $.request('payments/pay', 'POST', {
- order_id: id,
- order_type: type
- }).then((res) => {
- if (res.msg) {
- const {
- timestamp,
- paySign,
- nonceStr
- } = res.msg;
- const pck = res.msg.package;
- wx.requestPayment({
- timeStamp: timestamp + '',
- nonceStr,
- package: pck,
- signType: 'MD5',
- paySign,
- success(res) {
- console.log('支付成功', res);
- $.wx.hideToast('loading');
- _this.init();
- },
- fail() {
- $.wx.showToast({
- title: '支付失败'
- });
- }
- });
- }
- });
- }
- },
- addComment(e) {
- const {
- id,
- type
- } = e.target.dataset;
- if (id) {
- $.router.goto({
- path: '/pages/addComment/index',
- query: {
- id,
- type
- }
- });
- }
- }
- });
|