瀏覽代碼

小程序:个人中心

panyong 2 年之前
父節點
當前提交
a9421cd344

+ 0 - 19
htmldev/wxMini/README.md

@@ -53,25 +53,6 @@
 * 我的
   * 申请入驻 -> 填写表单:需要审核 -> 变成商户
   * 农户收藏:收藏之后的展示、在哪里去收藏
-  * 设置去掉,加个退出登录按钮
-
-* 商户端
-  * 已发布产品:点击去产品管理 已上架 tab
-  * 视频管理:入口去除
-  * 我的发布:展示最近上架的3个,点击去产品管理 已上架 tab
-
-* 产品管理
-  * 删除产品、编辑
 
 * 商户消息:
   * 二级页面 ???
-
-* 产品编辑
-  * 商品品牌:下拉选择
-  * 单位:下拉选择
-  * 商品货号:系统自动生成(只读)
-  * 批发价
-  * 零售价
-  * 库存
-  * 状态:现售产品有上架、下架状态
-  * 发售时间:不能低于当前创建时间

+ 54 - 2
htmldev/wxMini/pages/businessGoodsEdit/businessGoodsEdit.js

@@ -6,9 +6,31 @@ Page({
    * 页面的初始数据
    */
   data: {
+    // * 商品品牌:下拉选择
+    // * 单位:下拉选择
+    // * 商品货号:系统自动生成(只读)
+    // * 批发价
+    // * 零售价
+    // * 库存
+    // * 状态:现售产品有上架、下架状态
+    // * 发售时间:不能低于当前创建时间
     form: {
-      'photo': []
-    }
+      'product_img_url': [], // 商品主图
+      'product_rotation_img_list': [], // 商品轮播图
+      'product_detail_img_list': [], // 详情图
+      'product_title': '测试商品', // 商品标题
+      'product_category_id': 1, // 分类ID
+      'product_brand_id': 1, // 品牌ID
+      'product_spec': 'xl', // 规格
+      'product_unit': '个', // 单位
+      'product_all_price': 10000, // 批发价
+      'product_price': 9000, // 零售价
+      'product_count': 1000, // 库存
+      'product_sale_at': 0 // 预售时间(0代表预售)
+    },
+    product_img_url_max: 1,
+    product_rotation_img_list_max: 5,
+    product_detail_img_list_max: 5
   },
 
   /**
@@ -67,6 +89,36 @@ Page({
 
   },
   ...uploadJS,
+  uploadCallBack(res) {
+    const temp = res.map(item => {
+      return {
+        'url': item.url,
+        'formkey': item.formkey
+      }
+    })
+    let tempForm = {}
+    let formkey = ''
+    if (temp.length > 0) {
+      formkey = temp[0].formkey
+    }
+
+    switch (formkey) {
+      case 'product_img_url':
+        tempForm[`form.${formkey}`] = temp
+        break
+      case 'product_rotation_img_list':
+      case 'product_detail_img_list':
+        tempForm[`form.${formkey}`] = this.data.form[formkey].concat(...temp)
+        break
+      default:
+    }
+
+    console.log(tempForm)
+
+    if (Object.keys(tempForm).length > 0) {
+      this.setData(tempForm)
+    }
+  },
   onSubmit(e) {
     console.log(e.detail)
   }

+ 18 - 15
htmldev/wxMini/pages/businessGoodsEdit/businessGoodsEdit.wxml

@@ -4,17 +4,18 @@
       <view class="photo">
         <label>
           <text>商品主图</text>
-          <text>(0/1)</text>
+          <text>({{form.product_img_url.length}}/{{product_img_url_max}})</text>
         </label>
         <view class="value">
           <view
             class="van-uploader-wrap">
             <van-uploader
-              file-list="{{ form.photo }}"
+              file-list="{{ form.product_img_url }}"
+              max-count="{{product_img_url_max}}"
               multiple="{{false}}"
-              max-count="1"
               accept="image"
-              data-formkey="photo"
+              data-formkey="product_img_url"
+              bind:click-preview="uploadImg"
               bind:after-read="afterRead"
               bind:delete="delete"/>
           </view>
@@ -23,17 +24,18 @@
       <view class="swiper-photo">
         <label>
           <text>商品轮播图</text>
-          <text>(1/5)</text>
+          <text>({{form.product_rotation_img_list.length}}/{{product_rotation_img_list_max}})</text>
         </label>
         <view class="value">
           <view
             class="van-uploader-wrap">
             <van-uploader
-              file-list="{{ form.photo }}"
-              multiple="{{false}}"
-              max-count="1"
+              file-list="{{ form.product_rotation_img_list }}"
+              max-count="{{product_rotation_img_list_max}}"
+              multiple="{{true}}"
               accept="image"
-              data-formkey="photo"
+              data-formkey="product_rotation_img_list"
+              bind:click-preview="uploadImg"
               bind:after-read="afterRead"
               bind:delete="delete"/>
           </view>
@@ -42,17 +44,18 @@
       <view class="swiper-photo">
         <label>
           <text>商品详情图</text>
-          <text>(1/5)</text>
+          <text>({{form.product_detail_img_list.length}}/{{product_detail_img_list_max}})</text>
         </label>
         <view class="value">
           <view
             class="van-uploader-wrap">
             <van-uploader
-              file-list="{{ form.photo }}"
-              multiple="{{false}}"
-              max-count="1"
+              file-list="{{ form.product_detail_img_list }}"
+              max-count="{{product_detail_img_list_max}}"
+              multiple="{{true}}"
               accept="image"
-              data-formkey="photo"
+              data-formkey="product_detail_img_list"
+              bind:click-preview="uploadImg"
               bind:after-read="afterRead"
               bind:delete="delete"/>
           </view>
@@ -65,7 +68,7 @@
         </label>
         <view class="value">
           <input
-            value=""
+            value="{{form.product_title}}"
             placeholder="输入商品标题"
             placeholder-class="placeholder"></input>
         </view>

+ 2 - 2
htmldev/wxMini/project.private.config.json

@@ -7,8 +7,8 @@
     "miniprogram": {
       "list": [
         {
-          "name": "1111",
-          "pathName": "pages/mine/mine",
+          "name": "111",
+          "pathName": "pages/businessGoodsEdit/businessGoodsEdit",
           "query": "",
           "launchMode": "default",
           "scene": null