xuxueyang
2024-09-24 1d782559b682f7eb7a374c2e8017ff65cb941e52
pages/home/supplier-home.vue
@@ -13,15 +13,37 @@
         </view>
         <view class="flex user-info" v-if="currentInfo&&(currentInfo.id)">
            <image class="user-icon" v-if="
               (currentInfo.customerDTO&&currentInfo.customerDTO.cover)
               ||(currentInfo.supplierDTO&&currentInfo.supplierDTO.cover)
               ||(currentInfo.partnerDTO&&currentInfo.partnerDTO.cover)
               || currentInfo.picture
               " :src="
               (currentInfo.customerDTO&&currentInfo.customerDTO.cover)
               ||(currentInfo.supplierDTO&&currentInfo.supplierDTO.cover)
               ||(currentInfo.partnerDTO&&currentInfo.partnerDTO.cover)
               || currentInfo.picture
               " mode="scaleToFill"></image>
            <image class="user-icon" v-else
               src='https://youzhen123.oss-cn-huhehaote.aliyuncs.com/WechatOwnerProperty/images/mrtx.png'
               mode="scaleToFill"></image>
            <!-- 头像 -->
            <image class="user-icon" v-if="!currentInfo.picture" src="../../static/imgs/home/home-shop-top-icon.png"
         <!--    <image class="user-icon" v-if="!currentInfo.picture"
               src='https://youzhen123.oss-cn-huhehaote.aliyuncs.com/WechatOwnerProperty/images/mrtx.png'
               mode="aspectFit"></image>
            <image class="user-icon" v-if="currentInfo.picture" :src="currentInfo.picture" mode="aspectFit"></image>
            <image class="user-icon" v-if="currentInfo.picture" :src="currentInfo.picture" mode="aspectFit"></image> -->
            <view class="name">
               <view class="t1">{{ (!!currentInfo.supplierDTO?(currentInfo.supplierDTO.name):"") || currentInfo.nickName || currentInfo.loginName || '-'}}<span
               <view class="t1">
                  {{ (!!currentInfo.supplierDTO?(currentInfo.supplierDTO.name):"") || currentInfo.nickName || currentInfo.loginName || '-'}}<span
                     v-if="currentInfo.supplierDTO&&currentInfo.supplierDTO.status!=='P'">
                     ({{currentInfo.supplierDTO?currentInfo.supplierDTO.statusStr:''}})</span>
                  <span v-if="currentInfo.partnerDTO&&currentInfo.partnerDTO.status!=='P'">
                     ({{currentInfo.partnerDTO?currentInfo.partnerDTO.statusStr:''}})</span>
                  <span v-if="!currentInfo.partnerDTO&&currentInfo.type==='partner'">(信息待完善)</span>
               </view>
               <view class="t2">{{currentInfo.tel || '暂无电话'}}</view>
            </view>
@@ -34,7 +56,7 @@
         <view class="flex tj-container" v-if="selftype==='partner'">.
            <view class="tj-each">
               <view class="num total">
                  ¥999.80
                  ¥{{tj.income||'0.00'}}
               </view>
            </view>
            <view class="tj-each" style="flex: 1;">
@@ -44,11 +66,11 @@
            </view>
         </view>
         <view class="line"></view>
         <view class="flex tj-container" v-if="selftype==='supplier'">
            <view class="tj-each">
               <view class="num">
                  0扎
                  {{tj.dealCountLastMonth||0}}扎
               </view>
               <view class="name">
                  上月成交
@@ -56,7 +78,7 @@
            </view>
            <view class="tj-each">
               <view class="num">
                  0扎
                  {{tj.dealCountToday||0}}扎
               </view>
               <view class="name">
                  今日成交
@@ -64,7 +86,7 @@
            </view>
            <view class="tj-each">
               <view class="num">
                  0扎
                  {{tj.dealCountDay30||0}}扎
               </view>
               <view class="name">
                  近30天成交
@@ -72,25 +94,25 @@
            </view>
         </view>
         <view class="flex tj-container">
            <view class="tj-each">
            <view class="tj-each" @click="selftype=='supplier'&&goto('/pages/order/order-delivery?range=today',true)">
               <view class="num">
                  0扎
                  {{tj.orderCountToday||0}}单
               </view>
               <view class="name">
                  今日订单数
               </view>
            </view>
            <view class="tj-each">
            <view class="tj-each" @click="selftype=='supplier'&&goto('/pages/order/order-delivery?range=yesterday',true)">
               <view class="num">
                  0扎
                  {{tj.orderCountYesterday||0}}单
               </view>
               <view class="name">
                  昨日订单数
               </view>
            </view>
            <view class="tj-each">
            <view class="tj-each" @click="selftype=='supplier'&&goto('/pages/order/order-delivery?range=month',true)">
               <view class="num">
                  0扎
                  {{tj.orderCountMonth||0}}单
               </view>
               <view class="name">
                  本月订单数
@@ -98,18 +120,20 @@
            </view>
         </view>
      </view>
      <view class="item-container flex m-t-12" style="padding: 34rpx 44rpx;">
      <view class="item-container flex m-t-12" style="padding: 34rpx 44rpx;" v-if="selftype=='supplier'">
         <view class="rate-view flex1" style="max-width: 140rpx;">
            <view class="title">售后率</view>
            <view class="title" style="color: red;">0.00%</view>
            <view class="title" style="color: red;">{{((tj.salesRate||0)*100).toFixed(2)}}%</view>
         </view>
         <view class="tj-panel  pink flex1">
         <view class="tj-panel  pink flex1"
            @click="goto('/pages/order/order-delivery?status=PENDING&range=today',true)">
            <view class="name">今日待配送</view>
            <view class="title">0扎</view>
            <view class="title">{{tj.deliverCount||0}}扎</view>
         </view>
         <view class="tj-panel green flex1">
         <view class="tj-panel green flex1"
            @click="goto('/pages/order/order-delivery?range=today',true)">
            <view class="name green">今日配送汇总</view>
            <view class="title">0扎</view>
            <view class="title">{{tj.deliverTotal||0}}扎</view>
         </view>
      </view>
      <view class="m-t-12" @click="getNoticeMore">
@@ -127,6 +151,14 @@
                     src="/static/images/partner/user/user-icon-ddgl.png" mode="scaleToFill" />
               </view>
               <view class="order-desc tg">订单管理</view>
            </view>
            <view class="nav row margin-tb" v-if="selftype==='supplier'"
               @click="goto('/sub_pages/supplier/order-manage/order-manage',true)">
               <view class="img-c">
                  <image class="icon margin-bottom order-icon ddgl"
                     src="/static/images/partner/user/user-icon-ddgl.png" mode="scaleToFill" />
               </view>
               <view class="order-desc tg">订单统计</view>
            </view>
            <view class="nav row margin-tb"
@@ -152,20 +184,20 @@
               </view>
               <view class="order-desc tg">加价配置</view>
            </view>
            <view class="nav row margin-tb" @click="goto('/sub_pages/supplier/order-sale/order-sale',true)">
            <view class="nav row margin-tb" @click="goto('/pages/order/order-sale/order-sale',true)">
               <view class="img-c">
                  <image class="icon margin-bottom order-icon shlp"
                     src="/static/images/supplier/user/user-icon-shlp.png" mode="scaleToFill" />
               </view>
               <view class="order-desc syst">售后理赔</view>
            </view>
            <view class="nav row margin-tb" @click="goto('/sub_pages/supplier/order-records/order-records',true)">
            <!-- <view class="nav row margin-tb" @click="printDeliveryOrder">
               <view class="img-c">
                  <image class="icon margin-bottom order-icon kkjl"
                     src="/static/images/supplier/user/user-icon-kkjl.png" mode="scaleToFill" />
               </view>
               <view class="order-desc wbsp">扣款记录</view>
            </view>
               <view class="order-desc wbsp">测试蓝牙</view>
            </view> -->
         </view>
      </view>
@@ -194,27 +226,66 @@
            },
            scrollable: false,
            cacheUserId: '',
            tj: {}
         };
      },
      onShareAppMessage() {
         let that = this;
         var name = that.currentInfo.customerDTO && that.currentInfo.customerDTO.name || that.currentInfo.supplierDTO &&
            that.currentInfo.supplierDTO.name || that.currentInfo.partnerDTO && that.currentInfo.partnerDTO.name || ''
         var url =
            `/pages/login/supplier-login?shareId=${this.currentInfo&&this.currentInfo.id||''}&shareName=${name||''}`; //你的转发页面路径拼接参数
         return {
            title: "花满芫",
            path: url,
         }
      },
      onShareTimeline() {
         let that = this;
         var name = that.currentInfo.customerDTO && that.currentInfo.customerDTO.name || that.currentInfo.supplierDTO &&
            that.currentInfo.supplierDTO.name || that.currentInfo.partnerDTO && that.currentInfo.partnerDTO.name || ''
         var url =
            `/pages/login/supplier-login?shareId=${this.currentInfo&&this.currentInfo.id||''}&shareName=${name||''}`; //你的转发页面路径拼接参数
         return {
            title: "花满芫",
            path: url,
         }
      },
      async onPullDownRefresh() {
         await this.$store.dispatch('getCurrentInfo')
         await getTj(true)
         uni.stopPullDownRefresh()
      },
      onLoad(options) {
         const url = options.q ? decodeURIComponent(options.q) : '';
         const urlcode = options.url && decodeURIComponent(options.url) || ''
      },
      onShow() {
         this.getTj(true)
      },
      created() {
         //公告
         this.$http.request('get', '/api/announcement/page', {
         var type = ''
         // #ifdef PUB_CUSTOMER
         type = 'customer'
         // #endif
         // #ifdef PUB_SUPPLIER
         type = 'supplier'
         // #endif
         // #ifdef PUB_PARTNER
         type = 'partner'
         // #endif
         this.$http.request('get', '/api/pub/announcement/list/'+type, {
            params: {
               size: 5,
               status: 'A'
            }
         }).then(res => {
            if (res.code == 0) {
               this.noticeList = (res.data && res.data.records || [])
               this.noticeList = (res.data && res.data || [])
               console.log('this.noticeList', this.noticeList)
               if (this.noticeList.length > 0) {
                  this.currentNotice = this.noticeList[0]
@@ -249,9 +320,164 @@
      },
      methods: {
         printDeliveryOrder(item) {
            //蓝牙打印
            var that = this;
            wx.getBluetoothAdapterState({
               success: (result) => {
                  console.log('b s', result)
                  console.log("蓝牙状态:\n" + result.errMsg)
                  if (result.adapterState.available) {
                     if (result.adapterState.discovering) {
                        that.blueSearchDeviceCheck()
                     } else {
                        that.blueSearchDevice()
                     }
                  } else {
                     //打开蓝牙
                     wx.openBluetoothAdapter({
                        success: function(res) {
                           console.log("蓝牙已打开")
                           that.blueSearchDevice()
                        },
                        fail: function(res) {
                           console.log('res', res)
                           that.$message.showToast('蓝牙未打开')
                        }
                     })
                  }
               },
               fail: (res) => {
                  console.log("蓝牙状态", res)
                  that.$message.showToast('获取蓝牙状态失败')
               }
            })
         },
         blueSearchDevice() {
            var that = this;
            wx.startBluetoothDevicesDiscovery({
               success: (res) => {
                  //打印调试日志
                  console.log("搜索设备返回" + JSON.stringify(res))
                  that.blueSearchDeviceCheck()
               },
               fail: (res) => {
                  console.log('error search', res)
                  that.$message.showToast('打开蓝牙搜索设备失败')
               }
            })
         },
         blueSearchDeviceCheck() {
            let that = this
            wx.getBluetoothDevices({
               success: (res) => {
                  var printDevice = undefined
                  for (var device of res.devices) {
                     if (device.name.indexOf('GP-M') >= 0) {
                        printDevice = device
                        // RSSI: -57
                        // advertisServiceUUIDs: Array(2)
                        // 0: "000018f0-0000-1000-8000-00805f9b34fb"
                        // 1: "e7810a71-73ae-499d-8c15-faa9aef0c3f2"
                        // length: 2
                        // nv_length: (...)
                        // __proto__: Array(0)
                        // deviceId: "89:E2:AF:33:46:2B"
                        // name: "GP-M322-5565_BLE"
                        break
                     } else {
                     }
                  }
                  if (!printDevice) {
                     that.$message.showToast('未找到可用打印机,请联系客服')
                     that.stopBluetoothDevicesDiscovery()
                  } else {
                     wx.createBLEConnection({
                        deviceId: printDevice.deviceId,
                        success: function(res) {
                           // https: //blog.csdn.net/weixin_51375107/article/details/116009436
                           console.log('连接设备返回:' + res.errMsg);
                           that.$message.showToast('连接设备返回:' + res.errMsg)
                           // escpos怎么来 →点击查看智谱清言的回答https://chatglm.cn/share/FEXaC
                        },
                        fail: function(res) {
                           console.log('createBLEConnection fail', res)
                           that.$message.showToast('连接打印机失败')
                        },
                        complete() {
                           that.stopBluetoothDevicesDiscovery()
                        }
                     })
                  }
                  // res.devices.forEach((device, i) => {
                  //    console.log('device',
                  //       device)
                  //    // if (device.deviceId == that.data
                  //    //    .deviceId) {
                  //    //    console.log("物联网设备已找到")
                  //    //    that.$message.showToast(
                  //    //       '打印设备已找到')
                  //    //    return;
                  //    // }
                  // })
               },
               fail: (res) => {
                  console.log('getBluetoothDevices',
                     res)
                  that.$message.showToast('获取蓝牙设备失败')
               }
            })
         },
         stopBluetoothDevicesDiscovery() {
            var that = this;
            wx.stopBluetoothDevicesDiscovery({
               success: (res) => {
                  console.log("停止扫描设备")
               },
            })
         },
         getTj(refresh=false) {
            // /api/supplier/delivery
            if (this.currentInfo.id && (this.currentInfo.id !== this.cacheUserId || refresh)) {
               this.cacheUserId = this.currentInfo.id
               let that = this
               setTimeout(() => {
                  //其他统计
                  // #ifdef PUB_SUPPLIER
                  this.$http.request('get', '/api/supplier/delivery/statistics', {}).then(res => {
                     if (res.code === 0) {
                        that.tj = res.data || {}
                     }
                  })
                  // #endif
                  // #ifdef PUB_PARTNER
                  this.$http.request('get', '/api/partner/order/statistics', {}).then(res => {
                     if (res.code === 0) {
                        that.tj = res.data || {}
                     }
                  })
                  // #endif
               }, 200)
            }
         },
         async toFlowManage() {
            if (!this.currentInfo.supplierDTO) {
               await this.$message.confirm('尚未入驻店铺信息,是否前往入驻?')
               this.goto('/sub_pages/supplier/supplier-info/supplier-info', true)
@@ -262,7 +488,7 @@
               this.$message.showLoading()
               await this.$store.dispatch('getCurrentInfo')
               this.$message.hideLoading()
               if (this.currentInfo.supplierDTO.status == 'P') {
               } else {
@@ -277,6 +503,7 @@
               }
            }
            console.log('goto')
            this.goto('/sub_pages/supplier/flower-manage/flower-manage', true)
         },
         getNoticeMore() {