123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- import GoodApi from '../../../../services/good'
- import checkauth from '../../../../utils/checkauth'
- import Navi from '../../../../utils/navi'
- // pages/mine/myorder/confirm/index.ts
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- addrId: -1,
- address: {} as any,
- items: [] as any[],
- // pay: {} as any,
- // price: {} as any,
- wait: false,
- },
- behaviors: [checkauth],
- init() {
- this.setData({
- wait: true,
- })
- GoodApi.PreviewOrder({
- addrId: this.data.addrId,
- })
- .then((rsp) => {
- if (rsp.result) {
- this.setData({
- ...rsp.result,
- wait: false,
- })
- }
- })
- .catch(() => {
- this.setData({
- wait: false,
- })
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- //@ts-ignore
- onLoad(query: { addrId: number }) {
- const { addrId } = query
- this.setData({
- addrId,
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {},
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- const self = this
- //@ts-ignore
- this.afterAuth(() => {
- self.init()
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {},
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {},
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {},
- userAddr(addr: any) {
- this.setData({
- addrId: addr.id,
- address: {
- id: addr.id,
- name: addr.detailAddress,
- phone: addr.phone,
- detailAddress: addr.detailAddress,
- },
- })
- },
- gotoAddr() {
- Navi.navigateTo({
- url: '/pages/mine/myaddr/list/index?mode=choose&id=' + this.data.addrId,
- })
- },
- onConfirm() {
- const { items, pay = { mode: '' }, addrId } = this.data as any
- const bag: WxGoodComOrderDto = {
- addrId,
- items,
- couponId: undefined,
- payMode: pay.mode,
- expectMode: undefined,
- expectDate: undefined,
- }
- this.setData({
- wait: true,
- })
- GoodApi.MakeOrder(bag)
- .then((rsp) => {
- var reg = new RegExp('^\\d+$')
- debugger
- if (rsp.result && reg.test(rsp.result)) {
- this.setData(
- {
- wait: false,
- },
- () => {
- Navi.redirectTo({
- url: '/pages/mine/myorder/result/index?orderCode=' + rsp.result,
- })
- },
- )
- }
- })
- .catch((e) => {
- this.setData({
- wait: false,
- })
- })
- },
- })
|