Browse Source

小程序:个人中心

panyong 2 years ago
parent
commit
4b901d11f1

BIN
htmldev/wxMini/image/businessGoodsEdit/arrow.png


BIN
htmldev/wxMini/image/businessGoodsEdit/selected.png


BIN
htmldev/wxMini/image/businessGoodsEdit/unselected.png


BIN
htmldev/wxMini/image/businessHome/arrow.png


BIN
htmldev/wxMini/image/businessHome/bg.png


BIN
htmldev/wxMini/image/businessHome/eyes.png


BIN
htmldev/wxMini/image/businessHome/goods_manage.png


BIN
htmldev/wxMini/image/businessHome/goods_release.png


BIN
htmldev/wxMini/image/businessHome/message.png


BIN
htmldev/wxMini/image/businessHome/video_manage.png


+ 11 - 0
htmldev/wxMini/pages/businessHome/api/index.js

@@ -0,0 +1,11 @@
+const { request } = require('../../../api/request')
+
+/**
+ * 商户信息
+ * @returns {Promise<*>}
+ */
+export const getShopInfo = () => request({
+  url: '/api/shop/info',
+  method: 'POST',
+  showLoading: true
+})

+ 51 - 31
htmldev/wxMini/pages/businessHome/businessHome.js

@@ -1,3 +1,5 @@
+const { getShopInfo } = require('./api/index')
+
 Page({
 
   /**
@@ -6,33 +8,35 @@ Page({
   data: {
     nav: [
       {
-        icon: '',
+        icon: 'goods_release.png',
         name: '产品发布',
         path: 'businessGoodsEdit'
       },
       {
-        icon: '',
+        icon: 'goods_manage.png',
         name: '产品管理',
         path: 'businessGoodsManage'
       },
+      // {
+      //   icon: 'video_manage.png',
+      //   name: '视频管理',
+      //   path: 'businessVideoManage'
+      // },
       {
-        icon: '',
-        name: '视频管理',
-        path: 'businessVideoManage'
-      },
-      {
-        icon: '',
+        icon: 'message.png',
         name: '互动消息',
         path: 'businessLeavingAMessage'
       }
-    ]
+    ],
+    shopInfo: {},
+    products: []
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-
+    this.fetchShopInfo()
   },
 
   /**
@@ -61,27 +65,6 @@ Page({
    */
   onUnload() {
 
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
-
   },
   handleNav(e) {
     const { item } = e.currentTarget.dataset
@@ -90,5 +73,42 @@ Page({
     wx.navigateTo({
       url: `/pages/${path}/${path}`
     })
+  },
+  async fetchShopInfo() {
+    try {
+      // const { status, data } = await getShopInfo()
+      const { status, data, msg } = {
+        'status': true,
+        'data': {
+          'products': [
+            {
+              'product_title': '测试商品',
+              'product_price': 9000,
+              'id': 2,
+              'created_at': '2022-09-14 16:45:54'
+            }
+          ],
+          'user_nickname': 'sd',
+          'user_phone': '18768452697',
+          'user_head_img_url': 'sdsff',
+          'id': 1,
+          'product_total': 1
+        },
+        'code': 200,
+        'msg': '',
+        'url': ''
+      }
+      if (status) {
+        this.setData({
+          shopInfo: data,
+          products: data.products
+        })
+      } else {
+        wx.showToast({
+          title: msg,
+          icon: 'none'
+        })
+      }
+    } catch (err) {}
   }
 })

+ 8 - 14
htmldev/wxMini/pages/businessHome/businessHome.scss

@@ -22,7 +22,6 @@
     display: block;
     width: 100%;
     height: 100%;
-    background: pink;
   }
 }
 
@@ -54,7 +53,9 @@
   margin-top: 52rpx;
   margin-bottom: 50rpx;
   border-radius: 32rpx;
-  background: pink;
+  background-position: center center;
+  background-size: 100% 100%;
+  background-repeat: no-repeat;
 
   .data,
   .btn {
@@ -79,7 +80,6 @@
   image {
     width: 40rpx;
     height: 40rpx;
-    background: pink;
   }
 
   .check {
@@ -94,6 +94,7 @@
   left: 0;
   top: 0;
   display: flex;
+  justify-content: space-between;
   align-items: center;
   width: 690rpx;
   padding-left: 24rpx;
@@ -106,21 +107,16 @@
     content: '';
     position: absolute;
     left: 0;
-    top: 1rpx;
+    top: 6rpx;
     width: 14rpx;
     height: 37rpx;
     border-radius: 40rpx;
     background: #91B379;
   }
 
-  &:after {
-    content: '';
-    position: absolute;
-    right: 36rpx;
-    top: 0;
-    width: 40rpx;
-    height: 40rpx;
-    background: pink;
+  image {
+    width: 48rpx;
+    height: 48rpx;
   }
 }
 
@@ -141,7 +137,6 @@
   image {
     width: 104rpx;
     height: 104rpx;
-    background: pink;
   }
 
   text {
@@ -167,7 +162,6 @@
     display: block;
     width: 100%;
     height: 100%;
-    background: pink;
   }
 }
 

+ 26 - 14
htmldev/wxMini/pages/businessHome/businessHome.wxml

@@ -2,47 +2,59 @@
   <view class="width-690">
     <view class="user-info">
       <view class="portrait">
-        <image src=""></image>
+        <image src="{{shopInfo.user_head_img_url}}"></image>
       </view>
       <view class="user-name-wrap">
-        <view class="name">农户1234</view>
-        <view class="account">账号:12345678900</view>
+        <view class="name">{{shopInfo.user_nickname}}</view>
+        <view class="account">账号:{{shopInfo.user_phone}}</view>
       </view>
     </view>
 
-    <view class="dashboard">
+    <view
+      class="dashboard"
+      style="background-image: url('../../image/businessHome/bg.png')">
       <view class="data">
         <view class="label">已发布产品</view>
-        <view class="value">20</view>
+        <view class="value">{{shopInfo.product_total}}</view>
       </view>
       <view class="btn">
-        <image src=""></image>
+        <image src="../../image/businessHome/eyes.png"></image>
         <text class="check">查看详情</text>
       </view>
     </view>
-    <view class="excellent-goods-title">管理</view>
+    <view class="excellent-goods-title">
+      <text>管理</text>
+      <image src="../../image/businessHome/arrow.png"></image>
+    </view>
     <view class="nav-wrap">
       <view
         wx:for="{{nav}}"
         wx:key="index"
         data-item="{{item}}"
         bind:tap="handleNav">
-        <image src="{{item.icon}}"></image>
+        <image src="../../image/businessHome/{{item.icon}}"></image>
         <text>{{item.name}}</text>
       </view>
     </view>
-    <view class="excellent-goods-title">我的发布</view>
+    <view class="excellent-goods-title">
+      <text>我的发布</text>
+      <image src="../../image/businessHome/arrow.png"></image>
+    </view>
     <view class="main">
-      <view class="list">
+      <view
+        class="list"
+        wx:for="{{products}}"
+        wx:key="index">
         <view class="photo-wrap">
-          <image src=""></image>
+          <image src="{{item.product_img_url}}"></image>
         </view>
         <view class="box">
-          <view class="goods-name">山东大瓜山东大瓜山东大瓜山东大瓜</view>
-          <view class="add-time">2022/03/17  19:20</view>
+          <view class="goods-name">{{item.product_title}}</view>
+          <view class="add-time">{{item.created_at}}</view>
         </view>
-        <view class="price">产品价格:¥9.99</view>
+        <view class="price">产品价格:¥{{tools.fen2Yuan(item.product_price)}}</view>
       </view>
     </view>
   </view>
 </view>
+<wxs src="../../components/wxs/index.wxs" module="tools"></wxs>