zhao_js
2024-01-04 6898a19dcf7f52a1f93f8775cdfafc1685b4ee97
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<template>
    <view class="container" style="height: auto;">
        <view style="margin: 0.5rem;">
            <button class="mini-btn" style="background-color: cornflowerblue; margin-right: 10px;" type="primary"
                size="mini">素材下载</button>
            <button @click="toTab(2)" class="mini-btn" type="default" size="mini">短信审核</button>
            <button @click="toTab(3)" class="mini-btn" type="default" size="mini">微信朋友圈</button>
 
        </view>
        <view style="display: flex;flex-wrap: wrap; padding: 0.5rem;justify-content:space-between;">
            <view style="display: flex;flex-wrap: wrap;">
                <button @click="tongbu()" style="margin-right: 0.2rem;" type="primary">
                    商品同步
                </button>
                <button @click="getCount()" style="margin-right: 0.2rem;" type="primary">
                    查看铺货单
                </button>
                <button @click="clearHuo()" type="primary">
                    清除铺货单
                </button>
            </view>
 
            <view @click="refreshList()" class="refresh">
                刷新
            </view>
        </view>
        <cc-pullScroolView class="pullScrollView" ref="pullScroll" :enablePullDown="false" :back-top="false">
            <view>
                <view v-if="productList.length>0" class="orders-list d-flex flex-column w-100"
                    style="padding: 20rpx; padding-bottom: 0;">
                    <view class="order-item" v-for="(item, index) in productList" :key="index"
                        style="margin-bottom: 30rpx;">
                        <list-cell :hover="false">
                            <image :src="item.img"></image>
                        </list-cell>
                        <list-cell :hover="false" last>
                            <view class="w-100 d-flex flex-column">
                                <view class="w-100  font-size-lg text-color-base">
                                    {{ item.smscontent}}
                                </view>
                                <view class="w-100  font-size-lg text-color-base" style="margin-bottom: 20rpx;">
                                    <view>
                                        {{item.subject}}
                                    </view>
                                    <view style="color: #ef1913;">
                                        ¥{{item.min_price}}-{{item.max_price}}
                                    </view>
                                </view>
                                <view class="d-flex justify-content-between align-items-center"
                                    style="margin-bottom: 30rpx;">
                                    <!-- <view class="font-size-sm text-color-assist">
                                        {{item.wantsendtime}}
                                    </view> -->
                                    <view class="d-flex font-size-sm text-color-base align-items-center">
                                        <view style="display: flex;">
 
                                            <view style="display: flex;flex-wrap:wrap;" v-if="currentId==item.id">
                                                <view style="margin: 0.3rem;"
                                                    v-for="(linkitem, linkindex) in currentLink" :key="linkindex">
                                                    <button @click="download(linkitem)" type="primary">
                                                        图片{{linkindex}}
                                                    </button>
                                                </view>
                                                <view v-if="videoLink&&videoLink.length>0">
                                                    <button @click="download(videoLink)" type="primary">
                                                        主图视频
                                                    </button>
                                                </view>
                                            </view>
                                            <view v-else>
                                                <button type="primary"
                                                    style="background-color: #ef1913; margin-right: 5rem;"
                                                    @click="getProductDetail(item.id)">获取下载链接</button>
                                            </view>
                                        </view>
                                    </view>
                                </view>
                            </view>
                        </list-cell>
                    </view>
                </view>
 
            </view>
        </cc-pullScroolView>
    </view>
</template>
 
<script>
    import comUtils from '@/utils/ComUtils.js'
    export default {
        data() {
            return {
                currentTab: 0,
                productList: [],
                curPageNum: 1,
                pageCount: 10,
                totalNum: 0,
                currentLink: [],
                videoLink:'',
                currentId: ''
            }
        },
        onLoad(option) {
            //this.checkId();
            this.getTemplateData();
        },
 
        // 上拉加载
        onReachBottom() {
            if (this.curPageNum * this.pageCount < this.totalNum) {
                // 数据为加载完
                this.$refs.pullScroll.showUpLoading();
                this.curPageNum++;
                this.getTemplateData();
            }
        },
        methods: {
            //商品同步
            tongbu() {
                this.$http.post('/api/ProductManage/AddDistributebillTask', {}).then(e => {
                    if (e.result == true) {
                        uni.showToast({
                            title: '同步任务已提交,请稍后刷新页面',
                            icon: 'none'
                        });
                    }
 
                }).catch(function(err) {
                    console.log(err);
                })
            },
            refreshList() {
                this.productList = [];
                this.getTemplateData();
            },
            //查看铺货单
            getCount() {
                this.$http.post('/api/ProductInfo/DistributebillGet', {}).then(e => {
                    if (e.success == true) {
                        uni.showToast({
                            title: '当前铺货单共有' + e.result + '件商品',
                            icon: 'none'
                        });
                    }
 
                }).catch(function(err) {
                    console.log(err);
                })
            },
            //清除铺货单
            clearHuo() {
                this.$http.post('/api/ProductInfo/ClearDistributebill', {}).then(e => {
                    if (e.success == true) {
                        uni.showToast({
                            title: '清除成功!',
                            icon: 'none'
                        });
                    }
 
                }).catch(function(err) {
                    console.log(err);
                })
            },
            //检查白名单
            checkId() {
                var openId = uni.getStorageSync('smsopenid');
                var whiteid = comUtils.getAllowdId(status);
                if (openId == "" || whiteid.indexOf(openId) < 0) {
                    uni.reLaunch({
                        url: '/pages/emptypage/nopermissions'
                    })
                } else {
                    this.getTemplateData();
                }
            },
            getProductDetail(id) {
                let param = {
                    ProductId: id
                }
                this.$http.post('/api/ProductInfo/GetDaiFaDetail', param).then(e => {
                    var prodetail = e.result;
                    var linkArr = prodetail.productImage.images;
                    //linkArr.push(prodetail.mainVedio);
                    this.currentLink = prodetail.productImage.images;
                    this.videoLink=prodetail.mainVedio;
                    this.currentId = id;
                }).catch(function(err) {
                    console.log(err);
                })
            },
            //下载
            download(link) {
                uni.showLoading({
                    title: '下载中'
                })
                uni.downloadFile({
                    url: link,
                    success: (res) => {
                        uni.hideLoading();
                        if (res.statusCode === 200) {
                             var oA = document.createElement("a");
                            oA.download = ''; // 设置下载的文件名,默认是'下载'
                            oA.href = res.tempFilePath; //临时路径再保存到本地
                            document.body.appendChild(oA);
                            oA.click();
                            oA.remove(); // 下载之后把创建的元素删除 */
                        }
                    },
                    fail: (res) => {
                        uni.hideLoading();
                        
                    }
                });
            },
            toTab(tabtype) {
                var url = '';
                switch (tabtype) {
                    case 1:
                        url = '/pages/ad_page/product_sc';
                        break;
                    case 2:
                        url = '/pages/ad_page/sms_examine';
                        break;
                    case 3:
                        url = '/pages/ad_page/wx_pyqset';
                        break;
                }
                uni.navigateTo({
                    url: url
                })
            },
            getTemplateData() {
                let param = {
                    PageNo: this.curPageNum,
                    PageSize: this.pageCount
                }
                uni.showLoading({
                    title: '加载中'
                })
                this.$http.post('/api/ProductInfo/GetDaiFaProductList', param).then(e => {
                    this.totalNum = e.result.totalCount;
                    this.productList = this.productList.concat(e.result.data);
                    if (this.curPageNum * this.pageCount >= this.totalNum) {
                        // 如果是最后一页
                        this.$refs.pullScroll.finish();
                    } else {
                        // 不是最后一页
                        this.$refs.pullScroll.success();
                    }
                    uni.hideLoading()
                }).catch(function(err) {
                    uni.hideLoading()
                    console.log(err);
                })
 
 
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    page {
 
        height: 100%;
    }
 
    .taskid-show {
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        width: 80%;
    }
 
    .refresh {
        display: flex;
        align-items: center;
        color: #fff;
        background: #FF928F;
        padding: 0.6rem;
        border-radius: 10px;
        font-size: 0.8rem;
    }
 
    .container {
        display: flex;
        flex-direction: column;
        padding: 0.4rem;
    }
 
    .uni-flex {
        display: flex;
    }
 
    .uni-flex-row {
        @extend .uni-flex;
        flex-direction: row;
        box-sizing: border-box;
    }
 
    /* 列表footer */
    .uni-footer {
        @extend .uni-flex-row;
        justify-content: right;
        margin-top: $uni-spacing-col-lg;
    }
 
    .uni-footer-text {
        font-size: 14px;
        color: $uni-text-color-grey;
        margin-left: 5px;
        color: #FF928F;
        font-weight: 700;
    }
</style>