123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- import { get, post } from '../../utils/http'
- import { $wuxCountDown } from '../../components/dist/index'
- import { PROJECT_TYPE } from '../../utils/global'
- Page({
-
- data: {
- orderId: 0,
- orderData: {},
- isMember: -1,
- source: '',
- orderType: '',
- recommendList: [],
- productList: [],
- seconds: 0,
- countdownStr: '',
- takeOutTime: '',
- tips: {
- show_tips: 0,
- project: ['您的预约单已生效,请准时到店体验'],
- product: ['您的预约单已生效,请准时到店体验'],
- goods: ['您的预约单已生效', '请于_TIME_OUT_之前']
- },
- mainOrderId: -1,
- selectProductData: null
- },
-
- onLoad: function (options) {
- let that = this
- this.setData(
- {
- orderId: options.order_id,
- source: options.source || 'project',
- isMember:
- getApp().globalData.userInfo && getApp().globalData.userInfo.is_vip
- ? getApp().globalData.userInfo.is_vip
- : 0
- },
- () => {
- if(options.source === 'secondaryCard'){
- this.setData({
- orderType: options.source
- })
- return
- }
- that.getOrderSuccess(options.order_id)
- }
- )
- },
-
- onReady: function () {},
-
- onShow: function () {},
-
- onHide: function () {},
-
- onUnload: function () {
- if (this.c1) this.c1.stop()
- },
-
- onPullDownRefresh: function () {},
-
- onReachBottom: function () {},
-
- onShareAppMessage: function () {},
-
- getOrderSuccess(order_id) {
- let that = this
- let { source } = this.data
- if (source == 'product_with_project_order') {
- source = 'product'
- }
- get(
- 'api/order/success',
- {
- order_id,
- order_type: source
- },
- (res) => {
- let orderData = res.data
- this.setData(
- {
- orderData: orderData,
- productList: orderData.product_list,
- recommendList: orderData.recommend_list,
- takeOutTime: orderData.take_out_time,
- seconds: orderData.seconds,
- orderType: orderData.type,
- mainOrderId: orderData.main_order_id
- },
- () => {
- that.c1 = new $wuxCountDown({
- date: +new Date() + orderData.seconds * 1000,
- render(date) {
- const hours = this.leadingZeros(date.hours, 2)
- const min = this.leadingZeros(date.min, 2)
- const sec = this.leadingZeros(date.sec, 2)
- that.setData({ countdownStr: `${hours}:${min}:${sec}` })
- },
- onEnd() {
- that.c1.stop()
-
- }
- })
- }
- )
- console.log(res)
- }
- )
- },
-
- gotoOrderDetail() {
- let { orderType, orderId, mainOrderId } = this.data
- let _orderId = mainOrderId ? mainOrderId : orderId
- let url = `/pages/orderDetail/orderDetail?source=${orderType}&id=${_orderId}`
- if (['goods', 'cardgoods'].indexOf(orderType) > -1) {
- url = `/pages/goods/orderDetail/orderDetail?source=${orderType}&id=${_orderId}`
- }
- if(['secondaryCard'].indexOf(orderType) > -1){
- url = `/subPackages/pages/cardBag/cardBag`
- }
- wx.navigateTo({
- url: url
- })
- },
-
- gotoHome() {
- wx.switchTab({
- url: '/pages/home/home'
- })
- },
-
- gotoProductDetail(e) {
- let item = e.currentTarget.dataset.item
- wx.navigateTo({
- url: `/pages/projectDetail/projectDetail?source=product&project_id=${item.product_id}`
- })
- },
-
- gotoRecommendDetail(e) {
- let { source } = this.data
- let item = e.currentTarget.dataset.item
- if (source == 'product_with_project_order') {
- source = 'product'
- }
- wx.navigateTo({
- url: `/pages/projectDetail/projectDetail?source=${source}&project_id=${item.id}`
- })
- },
-
- selectProjectProduct(e) {
- let { selectProductData } = this.data
- let item = e.currentTarget.dataset.item
- if (selectProductData && selectProductData.product_id == item.product_id) {
- this.setData({ selectProductData: null })
- return
- }
- this.setData({ selectProductData: item })
- },
-
- addProductOrder() {
- let { selectProductData } = this.data
- if (!selectProductData) {
- wx.showToast({
- title: '请先选择升级产品',
- icon: 'none'
- })
- return
- }
- let source = 'product'
- let sourceType = PROJECT_TYPE[source]
- get(
- 'api/product/info',
- {
- store_id: wx.getStorageSync('store_id'),
- product_id: selectProductData.product_id,
- type: sourceType
- },
- (res) => {
-
- wx.navigateTo({
- url: `/pages/reserveProduct/reserveProduct?source=${source}&productData=${encodeURIComponent(
- JSON.stringify(res.data)
- )}`
- })
- }
- )
- }
- })
|