From 7295b3661539f41de32b81a0ce0150b36796f7a7 Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Thu, 5 Aug 2021 14:06:54 +0800 Subject: [PATCH] no message --- pages/home/customer-code/index.js | 34 ++++++++++++++++++++++++++--- pages/home/customer-code/index.wxml | 6 ++--- pages/home/customer-info/index.js | 2 +- pages/home/customer-list/index.js | 2 +- pages/home/customer-list/index.wxml | 6 ++--- 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/pages/home/customer-code/index.js b/pages/home/customer-code/index.js index 75a6d06..fde8830 100644 --- a/pages/home/customer-code/index.js +++ b/pages/home/customer-code/index.js @@ -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) } }) \ No newline at end of file diff --git a/pages/home/customer-code/index.wxml b/pages/home/customer-code/index.wxml index 3d08651..8569dff 100644 --- a/pages/home/customer-code/index.wxml +++ b/pages/home/customer-code/index.wxml @@ -2,14 +2,14 @@ 客户二维码 - + - {{name || ''}} + {{form.name || ''}} - 联系电话:18545124454 + 联系电话:{{form.mobile}} diff --git a/pages/home/customer-info/index.js b/pages/home/customer-info/index.js index e38f01d..fe34cd7 100644 --- a/pages/home/customer-info/index.js +++ b/pages/home/customer-info/index.js @@ -122,7 +122,7 @@ Scene({ saveCustomer(this.data.form).then(result => { wx.hideLoading() util.showBackToast('添加成功') - event.emit('EventMessage', { what: 101, detail: this.data.form }) + event.emit('EventMessage', { what: 102, detail: this.data.form }) }).catch(err => { wx.hideLoading() util.showToast(err) diff --git a/pages/home/customer-list/index.js b/pages/home/customer-list/index.js index 1cfa704..8038037 100644 --- a/pages/home/customer-list/index.js +++ b/pages/home/customer-list/index.js @@ -217,7 +217,7 @@ Scene({ this.data.index = e.currentTarget.dataset.index item = this.data.searchList[e.currentTarget.dataset.index] } - wx.navigateTo({ url: `/pages/home/customer-code/index?id=${item.id}&name=${item.name}` }) + wx.navigateTo({ url: `/pages/home/customer-code/index?id=${item.id}&userId=${item.userId}` }) }, addCustomer: function(){ wx.navigateTo({ url: `/pages/home/customer-info/index?` }) diff --git a/pages/home/customer-list/index.wxml b/pages/home/customer-list/index.wxml index 5be4fd2..89fe4cf 100644 --- a/pages/home/customer-list/index.wxml +++ b/pages/home/customer-list/index.wxml @@ -16,7 +16,7 @@ - + {{item.name || ''}} @@ -57,7 +57,7 @@ {{loading? '正在搜索' : '暂无数据'}} - + {{item.name || ''}} @@ -77,7 +77,7 @@ {{pageItem.sign}} - + {{item.name || ''}}