12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- const $ = global;
- const orderTexts = [
- '已预约,等待处理',
- '未付款',
- '已付款'
- ]
- new $.Page({
- data: {
- services: [],
- goods: []
- },
- onShow() {
- this.init();
- },
- init() {
- $.request('my/orders', 'GET', {}).then((res) => {
- const services = []
- const goods = []
- if (res.data && res.data.length > 0) {
- res.data.forEach(e => {
- e.orderText = orderTexts[e.status];
- if (e.order_type == 'product_order') {
- if (e.status == 0)
- e.orderText = '待付款';
- goods.push(e);
- } else {
- services.push(e);
- }
- });
- 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
- }
- });
- }
- }
- });
|