Browse Source

小程序:首页接口对接

panyong 2 years ago
parent
commit
ed5e1cb37a

+ 15 - 15
htmldev/wxMini/components/business-detail-large/index.js

@@ -2,7 +2,9 @@ Component({
   /**
    * 组件的属性列表
    */
-  properties: {},
+  properties: {
+    shopDetail: Object
+  },
 
   /**
    * 组件的初始数据
@@ -22,10 +24,7 @@ Component({
         name: '添加到手机通讯录',
         value: 'addPhoneContact'
       }
-    ],
-    businessInfo: {
-      phone: '13429176706'
-    }
+    ]
   },
 
   /**
@@ -40,17 +39,17 @@ Component({
     },
     async onSelect(event) {
       const { value } = event.detail
-      const { businessInfo } = this.data
+      const { shopDetail } = this.data
       this.hideActionSheet()
       switch (value) {
         case 'makePhoneCall':
           try {
-            await wx.makePhoneCall({ phoneNumber: businessInfo.phone })
+            await wx.makePhoneCall({ phoneNumber: shopDetail.shop_phone })
           } catch (err) {}
           break
         case 'setClipboardData':
           try {
-            await wx.setClipboardData({ data: businessInfo.phone })
+            await wx.setClipboardData({ data: shopDetail.shop_phone })
           } catch (err) {}
           break
         case 'addPhoneContact':
@@ -98,22 +97,23 @@ Component({
       } catch (err) {}
     },
     async addPhoneContactBridge() {
-      const { businessInfo } = this.data
+      const { shopDetail } = this.data
 
       try {
         await wx.addPhoneContact({
-          firstName: 'businessInfo.phone',
-          mobilePhoneNumber: businessInfo.phone
+          firstName: shopDetail.user_name,
+          mobilePhoneNumber: shopDetail.shop_phone
         })
       } catch (err) {}
     },
     async openLocationBridge() {
+      const { shop_address } = this.data.shopDetail
+
       try {
-        // 测试 latitude: 30.25727 longitude: 120.20523
         await wx.openLocation({
-          latitude: 30.25727,
-          longitude: 120.20523,
-          name: '浙江省杭州市余杭区'
+          latitude: shop_address.latitude,
+          longitude: shop_address.longitude,
+          name: shop_address.address_name
         })
       } catch (err) {}
     }

+ 1 - 1
htmldev/wxMini/components/business-detail-large/index.scss

@@ -44,7 +44,7 @@
   border-radius: 20rpx;
   box-shadow: 0 4rpx 20rpx 0 rgba(0, 0, 0, 0.1);
 
-  image {
+  .code {
     width: 404rpx;
     height: 400rpx;
     border-radius: 20rpx;

+ 4 - 4
htmldev/wxMini/components/business-detail-large/index.wxml

@@ -6,7 +6,7 @@
       class="label"
       src="../../image/common/location.png"></image>
     <view
-      class="value">地址:浙江省杭州市余杭区道良渚街道xx小区
+      class="value">地址:{{shopDetail.shop_address.address_name}}{{shopDetail.shop_address.name}}
     </view>
     <image
       class="arrow"
@@ -19,7 +19,7 @@
       class="label"
       src="../../image/common/tel.png"></image>
     <view
-      class="value">手机:12345678900
+      class="value">手机:{{shopDetail.shop_phone}}
     </view>
     <image
       class="arrow"
@@ -28,7 +28,7 @@
   <view class="qrcode">
     <image
       class="code"
-      src=""></image>
+      src="{{shopDetail.user_code_url}}"></image>
   </view>
   <view class="tip">长按扫码,添加微信</view>
 </view>
@@ -37,7 +37,7 @@
   show="{{ booShow }}"
   actions="{{ actions }}"
   cancel-text="取消"
-  description="13429176706可能是一个电话号码,你可以"
+  description="{{shopDetail.shop_phone}}可能是一个电话号码,你可以"
   close-on-click-overlay="{{false}}"
   bind:cancel="hideActionSheet"
   bind:select="onSelect"

+ 6 - 3
htmldev/wxMini/pages/businessDetail/businessDetail.js

@@ -23,8 +23,8 @@ Page({
         value: '2'
       }
     ],
-    active: '2',
-    objShopDetail: {}
+    active: '1',
+    objShopDetail: {shop_address: {}}
   },
   ...pages.methods,
   /**
@@ -98,7 +98,10 @@ Page({
       const { status, data, msg } = await getShopDetail(this.data.searchForm.shop_id)
       if (status) {
         this.setData({
-          objShopDetail: data
+          objShopDetail: {
+            ...data,
+            shop_address: JSON.parse(data.shop_address)
+          }
         })
       } else {
         wx.showToast({

+ 10 - 6
htmldev/wxMini/pages/businessDetail/businessDetail.wxml

@@ -1,20 +1,23 @@
 <!-- 轮播 -->
 <view class="page-section">
   <swiper
-    indicator-dots="{{true}}"
+    indicator-dots="{{false}}"
     indicator-color="rgba(130, 130, 130, 1)"
     indicator-active-color="#FFF"
     autoplay="{{false}}">
-    <block wx:for="{{background}}" wx:key="*this">
+    <block
+      wx:for="{{[objShopDetail.shop_img_url]}}"
+      wx:key="*this">
       <swiper-item>
-        <view class="swiper-item {{item}}">
-          <image src=""></image>
+        <view class="swiper-item">
+          <image
+            src="{{item}}"></image>
         </view>
       </swiper-item>
     </block>
   </swiper>
 </view>
-<view class="business-name">张三供应商</view>
+<view class="business-name">{{objShopDetail.user_name}}</view>
 <customer-tab
   nav="{{nav}}"
   active="{{active}}"
@@ -23,7 +26,8 @@
 <view
   class="business-info"
   hidden="{{active === '2'}}">
-  <business-detail-large/>
+  <business-detail-large
+    shopDetail="{{objShopDetail}}"/>
 </view>
   <!--产品-->
 <view

+ 0 - 1
htmldev/wxMini/pages/businessDetail/businessDetail.wxss

@@ -16,7 +16,6 @@
   display: block;
   width: 100%;
   height: 100%;
-  background: pink;
 }
 
 .business-name {