Browse Source

no message

feature/v2.2
xpz2018 4 years ago
parent
commit
7295b36615
5 changed files with 39 additions and 11 deletions
  1. 34
      pages/home/customer-code/index.js
  2. 6
      pages/home/customer-code/index.wxml
  3. 2
      pages/home/customer-info/index.js
  4. 2
      pages/home/customer-list/index.js
  5. 6
      pages/home/customer-list/index.wxml

34
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)
}
})

6
pages/home/customer-code/index.wxml

@ -2,14 +2,14 @@
<view slot="content">客户二维码</view>
</cu-custom>
<view style="padding:32rpx;margin-top:64rpx">
<view style="padding:32rpx;margin-top:64rpx" wx:if="{{form}}">
<van-cell clickable is-link>
<view slot="title" class="flex flex-justify" style="width:100%" bindtap="customerInfo">
<van-image round width="80rpx" height="80rpx" src="{{'/assets/image/ygImg.png' }}" />
<view style="width:100%;flex:1;margin-left: 18rpx">
<view class="text-sg text-bold">{{name || ''}}</view>
<view class="text-sg text-bold">{{form.name || ''}}</view>
<view class="text-sm text-gray" style="line-height:32rpx;height:32rpx">
<text>联系电话:18545124454</text>
<text>联系电话:{{form.mobile}}</text>
</view>
</view>
</view>

2
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)

2
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?` })

6
pages/home/customer-list/index.wxml

@ -16,7 +16,7 @@
</view>
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex">
<van-cell clickable wx:for="{{pageItem}}" wx:key="index">
<view slot="title" class="flex flex-justify" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="customerInfo">
<view slot="title" class="flex flex-justify" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="qrcodeCustomer">
<van-image round width="80rpx" height="80rpx" src="{{ item.avatarUrl || '/assets/image/ygImg.png' }}" />
<view style="margin-left:18rpx;width:100%;flex:1">
<view class="text-sg text-bold">{{item.name || ''}}</view>
@ -57,7 +57,7 @@
<view class="text-empty">{{loading? '正在搜索' : '暂无数据'}}</view>
</view>
<van-cell clickable wx:for="{{searchList}}" wx:key="index">
<view slot="title" class="flex flex-justify" data-index="{{index}}" bindtap="customerInfo">
<view slot="title" class="flex flex-justify" data-index="{{index}}" bindtap="qrcodeCustomer">
<!-- <van-image round width="80rpx" height="80rpx" src="{{ item.avatarUrl || '/assets/image/ygImg.png' }}" /> -->
<view style="width:100%;flex:1">
<view class="text-sg text-bold">{{item.name || ''}}</view>
@ -77,7 +77,7 @@
<text class="text-sg" style="line-height:50rpx;padding-left:32rpx">{{pageItem.sign}}</text>
</view>
<van-cell clickable wx:for="{{pageItem.data}}" wx:key="index">
<view slot="title" class="flex flex-justify" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="customerInfo">
<view slot="title" class="flex flex-justify" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="qrcodeCustomer">
<!-- <van-image round width="80rpx" height="80rpx" src="{{ item.avatarUrl || '/assets/image/ygImg.png' }}" /> -->
<view style="width:100%;flex:1">
<view class="text-sg text-bold">{{item.name || ''}}</view>

Loading…
Cancel
Save