|
@@ -6,24 +6,24 @@
|
|
|
<view class="step1" v-if="current==0">
|
|
|
<view class="form-row form-flex">
|
|
|
<view><text class="red">*</text>网点名称</view>
|
|
|
- <view>啊撒旦解放拉风小区</view>
|
|
|
+ <view>{{stationName}}</view>
|
|
|
</view>
|
|
|
<view class="form-row form-flex">
|
|
|
<view><text class="red">*</text>投递手机号</view>
|
|
|
<view>
|
|
|
- <u-input v-model="formData.phone" type="number" input-align="right" :custom-style="{color: '#666'}" :maxlength="11" placeholder="请输入手机号码"></u-input>
|
|
|
+ <u-input v-model="formData.customerMobile" type="number" input-align="right" :custom-style="{color: '#666'}" :maxlength="11" placeholder="请输入手机号码"></u-input>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="form-row">
|
|
|
<view><text class="red">*</text>投递类型</view>
|
|
|
<view class="form-grid">
|
|
|
- <view v-for="(item,index) in rubbishtype" :key="item.id" :class="index==0?'active':''">
|
|
|
+ <view v-for="(item,index) in rubbishtype" :key="item.id" @click="selRubbishType(item)" :class="formData.rubbishType==item.rubbishType?'active':''">
|
|
|
<view class="imgs">
|
|
|
- <u-image :src="`/static/${item.code}.png`" width="70rpx" height="70rpx"></u-image>
|
|
|
+ <u-image :src="`/static/${item.rubbishType}.png`" width="70rpx" height="70rpx"></u-image>
|
|
|
</view>
|
|
|
<view class="info">
|
|
|
- <view>{{item.dispName}}</view>
|
|
|
- <view class="texts">200g/1乐豆</view>
|
|
|
+ <view>{{item.rubbishTypeDictValue}}</view>
|
|
|
+ <view class="texts">{{item.rubbishWeight}}g/{{item.goleNum}}乐豆</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -32,17 +32,17 @@
|
|
|
<view class="step2" v-if="current==1">
|
|
|
<view class="form-row form-flex">
|
|
|
<view>投递手机号</view>
|
|
|
- <view>{{formData.phone}}</view>
|
|
|
+ <view>{{formData.customerMobile}}</view>
|
|
|
</view>
|
|
|
<view class="form-row form-flex">
|
|
|
<view>用户乐豆余额</view>
|
|
|
- <view class="flex-row"><text>560</text><u-image width="30rpx" height="30rpx" src="/static/ledou.png"></u-image></view>
|
|
|
+ <view class="flex-row"><text>{{currentGold}}</text><u-image width="30rpx" height="30rpx" src="/static/ledou.png"></u-image></view>
|
|
|
</view>
|
|
|
<view class="form-row form-flex">
|
|
|
<view>投递类型</view>
|
|
|
<view>
|
|
|
- 废旧衣服
|
|
|
- <text class="des">(200g/1乐豆)</text>
|
|
|
+ {{curRubbishType.rubbishTypeDictValue}}
|
|
|
+ <text class="des">({{curRubbishType.rubbishWeight}}g/{{curRubbishType.goleNum}}乐豆)</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="form-row form-flex">
|
|
@@ -51,11 +51,11 @@
|
|
|
</view>
|
|
|
<view class="form-row form-flex">
|
|
|
<view>可兑换乐豆数</view>
|
|
|
- <view class="flex-row"><text class="nums">10</text><u-image width="30rpx" height="30rpx" src="/static/ledou.png"></u-image></view>
|
|
|
+ <view class="flex-row"><text class="nums">{{goldNum}}</text><u-image width="30rpx" height="30rpx" src="/static/ledou.png"></u-image></view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="buttons">
|
|
|
- <view v-if="current==0" ><u-button shape="circle" :custom-style="customStyle" @click="next()" type="primary">下一步</u-button></view>
|
|
|
+ <view v-if="current==0" ><u-button shape="circle" :loading="loading" :custom-style="customStyle" @click="next()" type="primary">下一步</u-button></view>
|
|
|
<view v-if="current==1"><u-button shape="circle" @click="prev()">上一步</u-button></view>
|
|
|
<view v-if="current==1"><u-button shape="circle" @click="submit()" :custom-style="customStyle" type="primary">提交</u-button></view>
|
|
|
</view>
|
|
@@ -79,6 +79,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import {findBySrcDeviceNo, saveDelivery} from '@/api/delivery.js'
|
|
|
+ import {queryldByMobile} from '@/api/officialPartnerGoldLog.js'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -93,18 +95,30 @@
|
|
|
}, {
|
|
|
name: '称重'
|
|
|
}],
|
|
|
+ stationName: '', // 网点名称
|
|
|
formData:{
|
|
|
- address: '',
|
|
|
- phone: '',
|
|
|
- washType: '0',
|
|
|
- washWeight:0
|
|
|
+ customerMobile: '', // 客户电话
|
|
|
+ rubbishType: '', // 投递类型
|
|
|
+ rubbishWeight:0, // 投递重量
|
|
|
+ srcDeviceCode: '',
|
|
|
},
|
|
|
+ currentGold: 0, // 用户乐豆余额
|
|
|
blueConnect: true,
|
|
|
deviceId: null,
|
|
|
- rubbishtype: []
|
|
|
+ rubbishtype: [],
|
|
|
+ curRubbishType: null,
|
|
|
+ loading: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
+ // 计算可兑换乐豆
|
|
|
+ goldNum(){
|
|
|
+ let ret = 0
|
|
|
+ if(this.curRubbishType){
|
|
|
+ ret = this.balanceData / this.curRubbishType.rubbishWeight / this.curRubbishType.goleNum
|
|
|
+ }
|
|
|
+ return Math.floor(ret)
|
|
|
+ },
|
|
|
balanceData() {
|
|
|
this.cancel()
|
|
|
|
|
@@ -142,13 +156,15 @@
|
|
|
}
|
|
|
|
|
|
console.log(weight,uit,fh,'weight end')
|
|
|
- this.washWeight = weight
|
|
|
+ this.formData.rubbishWeight = weight
|
|
|
return fh + weight
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
let _this = this
|
|
|
- this.deviceId = options.deviceId
|
|
|
+ this.deviceId = options.deviceId.toLowerCase()
|
|
|
+ this.deviceId = this.deviceId.replace(/:/g,'')
|
|
|
+
|
|
|
// 连接中断
|
|
|
uni.$on('blueConnectClose',function(){
|
|
|
_this.reConnect(1)
|
|
@@ -167,14 +183,31 @@
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- // 投递类型
|
|
|
- this.rubbishtype = this.$store.state.vuex_rubbishType
|
|
|
+ // 通过设备id查询网点信息
|
|
|
+ this.findBySrcDeviceNo()
|
|
|
},
|
|
|
onUnload() {
|
|
|
uni.$off('blueConnectClose')
|
|
|
uni.$off('blueConnectCallback')
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 获取网点信息
|
|
|
+ findBySrcDeviceNo(){
|
|
|
+ findBySrcDeviceNo({srcDeviceCode:this.deviceId}).then(res=>{
|
|
|
+ console.log(res,'====')
|
|
|
+ if(res.status == 200){
|
|
|
+ this.rubbishtype = res.data.list
|
|
|
+ this.stationName = res.data.stationEntity.name
|
|
|
+ this.formData.srcDeviceCode = this.deviceId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 选择投递类型
|
|
|
+ selRubbishType(item){
|
|
|
+ this.formData.rubbishType = item.rubbishType
|
|
|
+ this.curRubbishType = item
|
|
|
+ },
|
|
|
+ // 重连蓝牙设备
|
|
|
reConnect(type){
|
|
|
this.blueConnect = false
|
|
|
uni.showModal({
|
|
@@ -190,36 +223,45 @@
|
|
|
})
|
|
|
},
|
|
|
next(){
|
|
|
- if(this.formData.phone == ''){
|
|
|
+ if(this.formData.customerMobile == ''){
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
title: '请输入手机号码'
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- if(this.formData.washType == ''){
|
|
|
+ if(this.formData.customerMobile.length!=11){
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
- title: '请选择投递类型'
|
|
|
+ title: '请输入正确的手机号码'
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- if(this.formData.phone.length!=11){
|
|
|
+ if(this.formData.rubbishType == ''){
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
- title: '请输入正确的手机号码'
|
|
|
+ title: '请选择投递类型'
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- this.current = this.current + 1
|
|
|
+
|
|
|
+ this.loading = true
|
|
|
+ // 查询用户余额
|
|
|
+ queryldByMobile({mobile: this.formData.customerMobile}).then(res => {
|
|
|
+ if(res.status == 200){
|
|
|
+ this.current = this.current + 1
|
|
|
+ this.currentGold = res.data.currentGold
|
|
|
+ }
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
},
|
|
|
prev(){
|
|
|
this.current = this.current - 1
|
|
|
},
|
|
|
submit(){
|
|
|
let that = this
|
|
|
- console.log(this.washWeight,'this.washWeight')
|
|
|
- if(this.washWeight<=0){
|
|
|
+ console.log(this.formData.rubbishWeight,'this.formData.rubbishWeight')
|
|
|
+ if(this.formData.rubbishWeight<=0){
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
title: '请投放物品!'
|
|
@@ -229,8 +271,11 @@
|
|
|
// 判断设备仍然连接中
|
|
|
uni.getBluetoothDevices({
|
|
|
success(res) {
|
|
|
- console.log(res.devices,that.deviceId)
|
|
|
- let has = res.devices.find(item => item.deviceId == that.deviceId)
|
|
|
+ let has = res.devices.find(item => {
|
|
|
+ let deviceId = item.deviceId.toLowerCase()
|
|
|
+ return deviceId.replace(/:/g,'') == that.deviceId
|
|
|
+ })
|
|
|
+ console.log(has,'判断设备仍然连接中')
|
|
|
if(that.blueConnect && has){
|
|
|
that.showOk = true
|
|
|
that.modelContent = `
|
|
@@ -252,7 +297,16 @@
|
|
|
},
|
|
|
// 确认提交
|
|
|
confirm(){
|
|
|
-
|
|
|
+ console.log(this.formData,'formData')
|
|
|
+ saveDelivery(this.formData).then(res => {
|
|
|
+ if(res.status == 200){
|
|
|
+ uni.navigateBack()
|
|
|
+ }
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: res.message
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -308,7 +362,6 @@
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
flex-wrap: wrap;
|
|
|
- justify-content: space-around;
|
|
|
> view{
|
|
|
width: 46%;
|
|
|
border: 1px solid #eee;
|