Browse Source

小程序:供应商接口对接

panyong 2 years ago
parent
commit
ab5e884c43

+ 15 - 1
htmldev/wxMini/app.wxss

@@ -164,7 +164,6 @@ view.footer-fixed-bottom button[type='default'] {
   display: block;
   width: 100%;
   height: 100%;
-  background-color: pink;
 }
 
 .app_nav-wrap .name {
@@ -259,3 +258,18 @@ view.footer-fixed-bottom button[type='default'] {
 .van-picker {
   --picker-confirm-action-color: #333;
 }
+
+.pulldown-wrapper,
+.pullup-wrapper {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  width: 100%;
+  height: 60px;
+}
+
+.van-loading__text {
+  color: #969799;
+  font-size: 14px;
+  line-height: 20px;
+}

+ 61 - 52
htmldev/wxMini/pages/business/business.js

@@ -1,51 +1,30 @@
+const pages = require('../../mixin/pages')
+const { getProductCategoryList } = require('../../api/common')
+
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    category: [{
-      name: '全部',
-      id: '1'
+    ...pages.data(),
+    listUrl: '/api/user/home/shop/list',
+    searchForm: {
+      key_words: '',
+      category_id: ''
     },
-      {
-        name: '分类',
-        id: '2'
-      },
-      {
-        name: '分类',
-        id: '3'
-      },
-      {
-        name: '分类',
-        id: '4'
-      },
-      {
-        name: '分类',
-        id: '5'
-      },
-      {
-        name: '分类',
-        id: '6'
-      }
-    ],
-    currentCategory: '1',
+    categoryList: [],
     navScrollLeft: -1,
-    pagenum: 0,
-    pagesize: 20,
-    finished: false, // 所有数据是否加载完
-    isRefresh: false, // 是否下拉刷新
-    isFetchLock: false, // 接口调用加锁
-    list: [1],
     booLock: false
   },
-  freshing: false,
+  ...pages.methods,
 
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad(options) {
-
+  async onLoad(options) {
+    await this.fetchProductCategoryList()
+    // this.fetchOrderList()
   },
 
   /**
@@ -80,39 +59,69 @@ Page({
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh() {
-
+    if (this.data.freshing) {
+      return
+    }
+    this.setData({
+      freshing: true
+    })
+    this.bindCallBack()
   },
 
   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom() {
-
+    this.fetchOrderList()
   },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
-
+  bindCallBack() {
+    this.refreshOrderList()
+  },
+  async fetchProductCategoryList() {
+    try {
+      const { status, data, msg } = await getProductCategoryList()
+      if (status && Array.isArray(data) && data.length > 0) {
+        this.setData({
+          categoryList: data.map(item => {
+            return {
+              ...item,
+              text: item.category_name
+            }
+          }),
+          'searchForm.category_id': data[0].id
+        })
+      } else {
+        wx.showToast({
+          title: msg,
+          icon: 'none'
+        })
+      }
+    } catch (err) {}
   },
   handleNav(e) {
-    const {
-      item
-    } = e.currentTarget.dataset
+    const { item } = e.currentTarget.dataset
+
+    if (this.data.searchForm.category_id !== item.id) {
+      this.setData({
+        'searchForm.category_id': item.id,
+        navScrollLeft: 0
+      }, () => {
+        this.refreshOrderList()
+      })
+    }
+  },
+  handleContact(e) {
+    const { item } = e.currentTarget.dataset
 
-    this.setData({
-      currentCategory: item.id,
-      navScrollLeft: 0
+    wx.makePhoneCall({
+      phoneNumber: item.shop_phone
     })
   },
   jumpBusinessDetail(e) {
-    const {
-      item
-    } = e.currentTarget.dataset
+    const { item } = e.currentTarget.dataset
 
     wx.navigateTo({
-      url: '/pages/businessDetail/businessDetail?businessId=' + item
+      url: '/pages/businessDetail/businessDetail?businessId=' + item.id
     })
   }
 })

+ 33 - 21
htmldev/wxMini/pages/business/business.wxml

@@ -1,53 +1,65 @@
 <view class="app_page-header-search page-header-search">
   <view class="app_page-header-search-warp app_width-690">
     <label for="header-search">
-      <image src=""></image>
+      <image src="../../image/common/search@2x.png"></image>
     </label>
-    <input placeholder-class="app_header-search-placeholder" value="" placeholder="搜索信息"></input>
+    <input
+      placeholder-class="app_header-search-placeholder"
+      value="{{searchForm.key_words}}"
+      placeholder="搜索信息"
+      data-formkey="key_words"
+      bind:input="handleKeyWords"></input>
   </view>
 </view>
 <scroll-view
   class="app_nav-wrap"
   scroll-x="{{true}}"
   scroll-with-animation="{{true}}"
-  scroll-into-view="item-{{currentCategory * 1 < 4 ? navScrollLeft : currentCategory * 1 - 3}}">
+  scroll-into-view="item-{{searchForm.category_id * 1 < 4 ? navScrollLeft : searchForm.category_id * 1 - 3}}">
   <view
-    class="nav {{currentCategory === item.id ? 'active' : ''}}"
-    wx:for="{{category}}"
+    class="nav {{searchForm.category_id === item.id ? 'active' : ''}}"
+    wx:for="{{categoryList}}"
     wx:key="id"
     data-item="{{item}}"
     bind:tap="handleNav">
     <view class="photo" id="item-{{index}}">
-      <image src=""></image>
+      <image src="{{item.category_img_url}}"></image>
     </view>
-    <view class="name">{{item.name}}</view>
+    <view class="name">{{item.category_name}}</view>
   </view>
 </scroll-view>
-<view class="list" wx:for="{{list}}" wx:key="index" data-item="{{item}}" bindtap="jumpBusinessDetail">
+<view
+  class="list"
+  wx:for="{{listData}}"
+  wx:key="index"
+  data-item="{{item}}"
+  bindtap="jumpBusinessDetail">
   <view class="item-info">
     <view class="top">
       <view class="logo">
-        <image class="" src=""></image>
+        <image src="{{item.shop_img_url}}"></image>
       </view>
       <view class="info">
-        <view class="name">名字名字名字名字名字名字名字名字</view>
-        <view class="goods-count">99999商品 9999999999人关注</view>
+        <view class="name">{{item.shop_name}}</view>
+        <view class="goods-count">{{item.shop_product_count}}商品 {{item.shop_follow_num}}人关注</view>
       </view>
-      <button class="contact" type="default">点击联系</button>
+      <button
+        class="contact"
+        type="default"
+        data-item="{{item}}"
+        catch:tap="handleContact">点击联系
+      </button>
     </view>
     <view class="bottom">
-      <button type="default">电话:12345678901</button>
-      <button type="default">微信:wxid_drq1i2lrkao22wxid_drq1i2lrkao22wxid_drq1i2lrkao22</button>
+      <button type="default">电话:{{item.shop_phone}}</button>
+      <button type="default">微信:{{item.user_wechat_code}}</button>
     </view>
   </view>
 </view>
-  <!-- 无数据 -->
-<view class="list-bitmap" wx:if="{{finished && list.length < 1}}">
-  <image src="system"></image>
-  <text>暂无数据</text>
-</view>
-  <!-- 上拉加载 -->
 <view class="pullup-wrapper" wx:if="{{!isRefresh}}">
-  <van-loading wx:if="{{!finished}}" size="24px" type="spinner">加载中...
+  <van-loading
+    wx:if="{{!finished}}"
+    size="24px"
+    type="spinner">加载中...
   </van-loading>
 </view>

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

@@ -32,7 +32,6 @@
   display: block;
   width: 100%;
   height: 100%;
-  background-color: pink;
 }
 
 .info {

+ 0 - 15
htmldev/wxMini/pages/businessGoodsManage/businessGoodsManage.scss

@@ -55,21 +55,6 @@
   background: #F6F6F6;
 }
 
-.pulldown-wrapper,
-.pullup-wrapper {
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  width: 100%;
-  height: 60px;
-}
-
-.van-loading__text {
-  color: #969799;
-  font-size: 14px;
-  line-height: 20px;
-}
-
 .list {
   width: 690rpx;
   min-height: 370rpx;

+ 0 - 15
htmldev/wxMini/pages/businessVideoManage/businessVideoManage.scss

@@ -55,21 +55,6 @@
   background: #F6F6F6;
 }
 
-.pulldown-wrapper,
-.pullup-wrapper {
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  width: 100%;
-  height: 60px;
-}
-
-.van-loading__text {
-  color: #969799;
-  font-size: 14px;
-  line-height: 20px;
-}
-
 .list {
   width: 690rpx;
   min-height: 370rpx;

+ 3 - 1
htmldev/wxMini/pages/home/home.js

@@ -22,7 +22,7 @@ Page({
       {
         icon: 'partner@2x.png',
         name: '供应商',
-        path: 'partner'
+        path: 'business'
       },
       {
         icon: 'guide@2x.png',
@@ -154,6 +154,8 @@ Page({
 
     this.setData({
       'searchForm.category_id': name
+    }, () => {
+      this.refreshOrderList()
     })
   },
   async isLeft() {

+ 0 - 14
htmldev/wxMini/pages/newGoods/newGoods.scss

@@ -9,17 +9,3 @@
 .main {
   padding: 58rpx 0 220rpx;
 }
-
-.pullup-wrapper {
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  width: 100%;
-  height: 50px;
-}
-
-.van-loading__text {
-  color: #969799;
-  font-size: 14px;
-  line-height: 20px;
-}

+ 4 - 2
htmldev/wxMini/pages/partner/partner.js

@@ -75,9 +75,11 @@ Page({
       url: '/pages/leavingAMessage/leavingAMessage'
     })
   },
-  jumpBusinessDetail() {
+  jumpBusinessDetail(e) {
+    const { item } = e.currentTarget.dataset
+
     wx.navigateTo({
-      url: '/pages/businessDetail/businessDetail'
+      url: '/pages/businessDetail/businessDetail?businessId=' + item.id
     })
   }
 })