123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import dayjs from 'dayjs'
- //@ts-ignore
- // import Toast from 'tdesign-miniprogram/toast/index'
- import GoodApi from '../../../../services/good'
- import checkauth from '../../../../utils/checkauth'
- import Navi from '../../../../utils/navi'
- // pages/mine/myorder/detail/index.ts
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- code: '',
- orderDate: '',
- followDate: '',
- showConfirm: false,
- },
- behaviors: [checkauth],
- init() {
- this.setData({
- wait: true,
- })
- GoodApi.GetOrderDetail({
- code: this.data.code,
- })
- .then((rsp) => {
- if (rsp.result) {
- const orderDate = dayjs(rsp.result.status.orderDate).format('YYYY-MM-DD HH:mm:ss')
- let followDate = rsp.result.status.followDate
- if (followDate && followDate.length > 0) {
- followDate = dayjs(followDate).format('YYYY-MM-DD HH:mm:ss')
- }
- this.setData({
- ...rsp.result,
- orderDate,
- followDate,
- wait: false,
- })
- }
- })
- .catch(() => {
- this.setData({
- wait: false,
- })
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- //@ts-ignore
- onLoad(query: { code: string }) {
- const { code = '' } = query
- this.setData({
- code,
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {},
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- const self = this
- //@ts-ignore
- this.afterAuth(() => {
- self.init()
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {},
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {},
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {},
- onCopyCode(e: WechatMiniprogram.CustomEvent<{}, {}, { code: string }>) {
- const { code = '' } = e.currentTarget.dataset
- if (code && code.length > 0) {
- wx.setClipboardData({
- data: code,
- // success() {
- // Toast({
- // context: this,
- // selector: '#t-toast',
- // message: '已复制到剪贴板',
- // icon: '',
- // duration: 1000,
- // })
- // },
- })
- }
- },
- onRebuy() {
- this.setData({
- showConfirm: true,
- })
- },
- confirmDialog() {
- this.setData({
- showConfirm: false,
- wait: true,
- })
- GoodApi.OrderDeplicate({
- code: this.data.code,
- })
- .then((rsp) => {
- if (rsp.result === 'ok') {
- Navi.switchTab({
- url: '/pages/cart/index',
- })
- }
- this.setData({
- wait: false,
- })
- })
- .catch(() => {
- this.setData({
- wait: false,
- })
- })
- },
- closeDialog() {
- this.setData({
- showConfirm: false,
- })
- },
- })
|