zhaoxiaohai 3 年之前
父节点
当前提交
e983b5680d
共有 2 个文件被更改,包括 23 次插入9 次删除
  1. 19 5
      components/My_accessory/index.js
  2. 4 4
      components/My_accessory/index.wxml

+ 19 - 5
components/My_accessory/index.js

@@ -1,4 +1,4 @@
-// components/My_accessory/index.js
+const cf = require("../../utils/checkFile")
 Component({
     /**
      * 组件的属性列表
@@ -7,6 +7,13 @@ Component({
         butType: {
             type: String,
             value: "下载"
+        },
+        list: {
+            type: Array,
+            value: []
+        },
+        callBack: {
+            type: Function
         }
     },
     options: {
@@ -24,11 +31,18 @@ Component({
      * 组件的方法列表
      */
     methods: {
-        butClick(){
-            console.log(this.data.butType)
+        butClick(e) {
+            const {
+                item
+            } = e.currentTarget.dataset;
+            if (this.data.butType == '播放') return this.triggerEvent("callBack", item);
         },
-        checkFile(){
-            console.log("查看文件")
+        checkFile(e) {
+            const {
+                item
+            } = e.currentTarget.dataset;
+            if (this.data.butType == '播放') return this.triggerEvent("callBack", item);
+            cf.checkFile(item);
         }
     }
 })

+ 4 - 4
components/My_accessory/index.wxml

@@ -1,10 +1,10 @@
-<navigator url="#" class="accessory my-card" wx:for="{{2}}" bindtap="checkFile">
+<navigator url="#" class="accessory my-card" wx:for="{{list}}" data-item="{{item}}" bindtap="checkFile">
     <view class="icon">
         <text class="iconfont icon-word" />
     </view>
     <view class="explian">
-        <view class="title line-1">销售策略销售策略销售策略销售策略</view>
-        <view class="time">2022-01-12 15:30</view>
+        <view class="title line-1">{{item.document}}</view>
+        <view class="time">{{item.createdate}}</view>
     </view>
-    <van-button type="{{butType==='下载'?'info':'danger'}}" custom-class='v-but' catchtap="butClick">{{butType}}</van-button>
+    <van-button type="{{butType==='下载'||butType==='播放'?'info':'danger'}}" data-item="{{item}}" custom-class='v-but' catchtap="butClick">{{butType}}</van-button>
 </navigator>