|
@@ -1,21 +1,28 @@
|
|
|
const _Http = getApp().globalData.http;
|
|
|
|
|
|
+import {
|
|
|
+ fileList
|
|
|
+} from "../../utils/FormatTheAttachment";
|
|
|
+
|
|
|
Page({
|
|
|
data: {
|
|
|
loading: true
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
- console.log(options)
|
|
|
if (options.id) this.setData({
|
|
|
- sa_itemgroupid: options.id
|
|
|
+ sa_itemgroupid: options.id,
|
|
|
+ itemno: 'BM8270 0150000'
|
|
|
})
|
|
|
this.getDetail()
|
|
|
},
|
|
|
+
|
|
|
+ /* 获取详情 */
|
|
|
getDetail() {
|
|
|
_Http.basic({
|
|
|
- "id": "20220926142403",
|
|
|
+ "id": "20221223165503",
|
|
|
"content": {
|
|
|
- "sa_itemgroupid": this.data.sa_itemgroupid
|
|
|
+ "sa_itemgroupid": this.data.sa_itemgroupid,
|
|
|
+ itemno: this.data.itemno
|
|
|
}
|
|
|
}).then(res => {
|
|
|
console.log("商品详情", res)
|
|
@@ -23,12 +30,72 @@ Page({
|
|
|
title: res.msg,
|
|
|
icon: "none"
|
|
|
})
|
|
|
+ this.handleFiles(res.data.item[0].attinfos)
|
|
|
this.setData({
|
|
|
- detail: res.data[0],
|
|
|
+ detail: res.data.item[0],
|
|
|
+ rows: res.data.rows,
|
|
|
loading: false
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ /* 预览媒体 */
|
|
|
+ viewMedias(e) {
|
|
|
+ const {
|
|
|
+ index,
|
|
|
+ type
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
+ wx.previewMedia({
|
|
|
+ current: index,
|
|
|
+ sources: type == 'image' ? this.data.files.viewImages : this.data.files.viewVideos,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 处理附件 */
|
|
|
+ handleFiles(arr) {
|
|
|
+ let files = {
|
|
|
+ images: [],
|
|
|
+ viewImages: [],
|
|
|
+ videos: [],
|
|
|
+ viewVideos: [],
|
|
|
+ files: []
|
|
|
+ },
|
|
|
+ list = fileList(arr);
|
|
|
+ list.forEach(v => {
|
|
|
+ switch (v.fileType) {
|
|
|
+ case "video":
|
|
|
+ files.videos.push(v)
|
|
|
+ files.viewVideos.push({
|
|
|
+ url: v.url,
|
|
|
+ type: "video",
|
|
|
+ poster: v.subfiles[0].url
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case "image":
|
|
|
+ files.images.push(v)
|
|
|
+ files.viewImages.push({
|
|
|
+ url: v.url,
|
|
|
+ type: "image"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ files.files.push(v)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ files
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 切换产品 */
|
|
|
+ changeItemno(e) {
|
|
|
+ const {
|
|
|
+ item
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
+ if (item.itemno == this.data.itemno) return;
|
|
|
+ this.setData({
|
|
|
+ itemno: item.itemno
|
|
|
+ });
|
|
|
+ this.getDetail();
|
|
|
+ },
|
|
|
/* 加入购物车 */
|
|
|
storage() {
|
|
|
_Http.basic({
|