|
|
|
@ -1,6 +1,8 @@ |
|
|
|
// pages/home/customer-info/index.js
|
|
|
|
import Scene from '../../index/scene' |
|
|
|
import { getCustomerInfo } from "../../../api/saas" |
|
|
|
const util = require('../../../utils/util') |
|
|
|
const event = require('../../../utils/event') |
|
|
|
const qrCode = require('../../../utils/weapp-qrcode') |
|
|
|
const app = getApp() |
|
|
|
|
|
|
|
@ -9,15 +11,38 @@ Scene({ |
|
|
|
* 页面的初始数据 |
|
|
|
*/ |
|
|
|
data: { |
|
|
|
name: '裕隆纸业有限公司', |
|
|
|
id: null, |
|
|
|
userId: null, |
|
|
|
form: null, |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad: function (options) { |
|
|
|
if(!util.isEmpty(options.id)){ |
|
|
|
this.showQrCode('?mark=ztb_saas&QrCodeRecordId=597399780326510592' + Math.ceil(Math.random() * 100) ) |
|
|
|
this.data.id = options.id |
|
|
|
this.data.userId = options.userId |
|
|
|
this.fetchCustomerInfo() |
|
|
|
} |
|
|
|
event.on('EventMessage', this, this.onEvent) |
|
|
|
}, |
|
|
|
onEvent: function(message){ |
|
|
|
if (message.what == 101) { |
|
|
|
wx.navigateBack() |
|
|
|
} else if (message.what == 102) { |
|
|
|
this.fetchCustomerInfo() |
|
|
|
} |
|
|
|
}, |
|
|
|
fetchCustomerInfo: function(){ |
|
|
|
wx.showLoading({ title: '正在获取', mask: true }) |
|
|
|
getCustomerInfo(this.data.id).then(result => { |
|
|
|
wx.hideLoading() |
|
|
|
this.setData({ form: result.data }) |
|
|
|
this.showQrCode(`?mark=ztb_saas&QrCodeRecordId=${this.data.id}` ) |
|
|
|
}).catch(err => { |
|
|
|
wx.hideLoading() |
|
|
|
util.showToast(err) |
|
|
|
}) |
|
|
|
}, |
|
|
|
rpx2px: function(rpx) { |
|
|
|
return rpx / 750 * app.globalData.windowWidth |
|
|
|
@ -41,6 +66,9 @@ Scene({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
customerInfo: function(){ |
|
|
|
|
|
|
|
wx.navigateTo({ url: `/pages/home/customer-info/index?id=${this.data.id}&userId=${this.data.userId}` }) |
|
|
|
}, |
|
|
|
onUnload: function(){ |
|
|
|
event.remove('EventMessage', this) |
|
|
|
} |
|
|
|
}) |