纸通宝小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

114 lines
3.2 KiB

// pages/order/order-info/index.js
const request = require('../../../utils/request') //导入模块
const util = require('../../../utils/util')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
backStr: '返回',
orderInfo: null,
imgList: [],
safeBottom: app.globalData.safeBottom,
kg: app.globalData.kg,
imageHeight: 0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (getCurrentPages().length == 1) {
this.setData({ backStr: '首页' })
}
if (options.id) {
wx.showLoading({ title: '加载中', mask: true })
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
this.biddingDialog = this.biddingDialog || this.selectComponent('#bidding-good')
this.fetchInfo(options.id)
}
},
fetchInfo: function (id) {
// /purchase/get/product/{productId} 查看采购商品详情接口
request.get('/recycle-service/purchase/get/product/' + id).then(result => {
//成功回调
this.setData({
imageHeight: 750,
safeBottom: app.globalData.safeBottom,
kg: app.globalData.kg,
orderInfo: result.data,
imgList: result.data.imgList
})
wx.hideLoading()
}).catch(err => {
//异常回调
wx.hideLoading()
util.showToast(err)
})
},
// 图片查看
viewImage: function (e) {
var imgList = []
for (let index = 0; index < this.data.imgList.length; index++) {
imgList.push(this.data.imgList[index])
}
wx.previewImage({ urls: imgList, current: e.currentTarget.dataset.url })
},
check: function(){
if (!app.globalData.userInfo.isVIP) {
this.wuxDialog.open({
resetOnClose: true,
title: '温馨提示',
content: '此功能仅限会员可以使用,是否开通会员?',
buttons: [{
text: '确定',
type: 'primary',
onTap(e) {
wx.navigateTo({ url: '/pages/ztbvip/index' })
}
}]
})
return false
}
return true
},
toShopInfo: function () {
if (!this.data.orderInfo) {
return
}
if(!app.globalData.userInfo){
wx.navigateTo({ url: '/pages/login/index'})
return
}
if(this.check()){
wx.navigateTo({ url: '/pages/shop/detail/index?storeId=' + this.data.orderInfo.storeId })
}
},
phoneShopInfo: function(){
if(!app.globalData.userInfo){
wx.navigateTo({ url: '/pages/login/index'})
return
}
if(this.check()){
wx.makePhoneCall({ phoneNumber: this.data.orderInfo.ownerPhone })
}
},
onShareAppMessage: function () {
var title = ''
if(this.data.orderInfo.locCityName){
title = this.data.orderInfo.locProvinceName + this.data.orderInfo.locCityName
}
title += '采购' + this.data.orderInfo.secondCategoryName
var imageUrl = '/assets/image/icon_logo.png'
if(this.data.orderInfo.imgList && this.data.orderInfo.imgList.length > 0){
imageUrl = this.data.orderInfo.imgList[0]
}
return {
title: title,
path: 'pages/index/index?url=/pages/purchase/detail/index&key=id&value=' + this.data.orderInfo.productId,
imageUrl: imageUrl,
success: function (res) {}
}
}
})