Selaa lähdekoodia

单品,首页更新优化

xiaohaizhao 1 vuosi sitten
vanhempi
commit
f062e6c0bb

+ 3 - 2
packageCase/electricAppliances/index.vue

@@ -39,12 +39,13 @@
             </view>
             <My_listbox ref="List" @getlist="getList">
                 <view class="list-box">
-                    <view class="item" v-for="item in list" :key="item.sa_fadid" hover-class="navigator-hover">
+                    <navigator class="item" :url="'/packageCase/product/detail?id=' + item.sa_fadid" v-for="item in list"
+                        :key="item.sa_fadid" hover-class="navigator-hover">
                         <image class="image" :src="item.cover" mode="aspectFill" lazy-load="true" />
                         <view class="title u-line-1">
                             {{ item.name }}
                         </view>
-                    </view>
+                    </navigator>
                 </view>
             </My_listbox>
         </view>

+ 3 - 13
packageCase/imgs/detail.vue

@@ -1,6 +1,5 @@
 <template>
     <My_listbox ref="List" @getlist="getDetail">
-
         <swiper class="swiper" v-if="slides.length" :indicator-dots="slides.length > 1" indicator-color="#DC808B"
             indicator-active-color="#C30D23">
             <swiper-item class="swiper-item" v-for="item in slides" :key="item.url">
@@ -11,7 +10,6 @@
                 </view>
             </swiper-item>
         </swiper>
-
         <view class="head">
             <view class="line1">
                 <view class="left">
@@ -74,10 +72,11 @@ export default {
     },
     onLoad(options) {
         this.sat_sharematerialid = options.id;
-        this.getDetail();
+        this.getDetail(true);
     },
     methods: {
-        getDetail() {
+        getDetail(init = false) {
+            if (!init) return;
             this.$Http.basic({
                 "id": 20240415164302,
                 "content": {
@@ -135,15 +134,6 @@ export default {
                                 showCancel: false
                             })
                             that.loading = false;
-                            this.$Http.basic({
-                                "id": 20240319142702,
-                                "content": {
-                                    sat_sharematerialid: that.detail.sat_sharematerialid, type: 1
-                                }
-                            }).then(res => {
-                                console.log(type, '记录', res)
-                            })
-
                         },
                         fail: ({ errMsg }) => {
                             if (errMsg == 'saveImageToPhotosAlbum:fail auth deny') {

+ 315 - 0
packageCase/product/detail.vue

@@ -0,0 +1,315 @@
+<template>
+    <My_listbox ref="List" @getlist="getDetail">
+
+        <swiper class="swiper" v-if="slides.length" :indicator-dots="slides.length > 1" indicator-color="#DC808B"
+            indicator-active-color="#C30D23">
+            <swiper-item class="swiper-item" v-for="item in slides" :key="item.url">
+                <image class="image" :src="item.cover" mode="aspectFill" lazy-load="true" />
+                <view class="qrcode" @click="saveQrcode">
+                    <text class="iconfont icon-xiazai" />
+                    二维码
+                </view>
+            </swiper-item>
+        </swiper>
+
+        <view class="head">
+            <view class="line1">
+                <view class="left">
+                    <text class="iconfont icon-biaoqian" />
+                    {{ detail.mainclassnames }}
+                </view>
+                <view class="right" hover-class="navigator-hover"
+                    @click="collectLoading ? '' : handleCollect(detail.iscollect)">
+                    <u-loading-icon v-if="collectLoading" size="20" />
+                    <block v-else>
+                        <text v-if="detail.iscollect == 0" class="iconfont icon-weishoucang" />
+                        <text v-else class="iconfont icon-yishoucang" style="color: #FFC300;" />
+                        收藏
+                    </block>
+                </view>
+            </view>
+            <view class="title">{{ detail.name }}</view>
+            <view class="subtitle">型号:{{ detail.model || '--' }}</view>
+            <view class="subtitle">尺寸:{{ detail.spec || '--' }}</view>
+            <view class="subtitle">价格:{{ CNY(detail.price) || '--' }}</view>
+        </view>
+
+        <view class="introduce">
+            <block v-if="detail.content">
+                <view class="introduce-title">
+                    产品介绍
+                </view>
+                <view class="introduce-text">
+                    <u-parse :content="detail.content" />
+                </view>
+            </block>
+        </view>
+        <bottom1 />
+        <view style="position: absolute;z-index: -999;top: 0;">
+            <l-painter ref="painter" hidden css="padding:10px;background:#fff;width: 148px;">
+                <l-painter-view>
+                    <l-painter-view css="margin: 0 auto;width: 128px;">
+                        <l-painter-qrcode :text="detail.appleturl" css="width: 128px; height: 128px;color:#000;" />
+                    </l-painter-view>
+                    <l-painter-view css="width: 108px;text-align: center;margin: 10px auto 0;">
+                        <l-painter-text :text="detail.name" />
+                    </l-painter-view>
+                </l-painter-view>
+            </l-painter>
+        </view>
+    </My_listbox>
+</template>
+
+<script>
+import bottom1 from "../../components/bottomModules/bottom1.vue"
+import lPainter from "../../uni_modules/lime-painter/components/l-painter/l-painter.vue"
+import lPainterText from "../../uni_modules/lime-painter/components/l-painter-text/l-painter-text.vue"
+import lPainterView from "../../uni_modules/lime-painter/components/l-painter-view/l-painter-view.vue"
+import lPainterQrcode from "../../uni_modules/lime-painter/components/l-painter-qrcode/l-painter-qrcode.vue"
+export default {
+    components: { bottom1, lPainter, lPainterQrcode, lPainterText, lPainterView },
+    data() {
+        return {
+            sa_fadid: null,
+            detail: {},
+            slides: [],
+            collectLoading: false
+        }
+    },
+    onLoad(options) {
+        this.sa_fadid = options.id;
+        this.getDetail(true);
+    },
+    methods: {
+        getDetail(init = false) {
+            if (!init) return;
+            this.$Http.basic({
+                "id": 20240418141002,
+                "content": {
+                    "sa_fadid": this.sa_fadid
+                },
+            }).then(res => {
+                this.$refs.List.RefreshToComplete()
+                console.log("获取单品详情", res)
+                if (this.cutoff(res.msg)) return;
+                this.detail = res.data;
+                this.slides = res.data.attinfos_pic.map(v => {
+                    return {
+                        cover: this.getSpecifiedImage(v.attinfos[0]),
+                        url: v.attinfos[0].url
+                    }
+                })
+                uni.setNavigationBarTitle({
+                    title: res.data.name
+                });
+            })
+        },
+        handleCollect(iscollect) {
+            this.collectLoading = true;
+            this.$Http.basic({
+                "id": 20240416133702,
+                "content": {
+                    "ownertable": "sa_fad",
+                    "ownerid": this.detail.sa_fadid,
+                    "type": 1
+                },
+            }).then(res => {
+                console.log("收藏", res)
+                this.collectLoading = false;
+                if (this.cutoff(res.msg)) return;
+                this.detail.iscollect = iscollect ? 0 : 1
+            })
+        },
+        saveQrcode() {
+            let that = this;
+            that.$refs.painter.canvasToTempFilePathSync({
+                fileType: "jpg",
+                // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
+                pathType: 'url',
+                quality: 1,
+                success: (res) => {
+                    console.log(res.tempFilePath);
+                    // 非H5 保存到相册
+                    // H5 提示用户长按图另存
+                    uni.saveImageToPhotosAlbum({
+                        filePath: res.tempFilePath,
+                        success: function (e) {
+                            uni.showModal({
+                                title: '提示',
+                                content: '图片已保存到系统相册',
+                                showCancel: false
+                            })
+                            that.loading = false;
+                        },
+                        fail: ({ errMsg }) => {
+                            if (errMsg == 'saveImageToPhotosAlbum:fail auth deny') {
+                                uni.showModal({
+                                    title: '提示',
+                                    content: '请授权添加到相册权限后再试!',
+                                    showCancel: false,
+                                    complete: (complete) => {
+                                        uni.openSetting({
+                                            success: res => {
+                                                that.loading = false;
+                                                if (res.authSetting['scope.writePhotosAlbum']) {
+                                                    this.saveTheImage()
+                                                } else {
+                                                    uni.showModal({
+                                                        title: '提示',
+                                                        content: '未获取授权!已取消保存',
+                                                        showCancel: false,
+                                                    })
+                                                }
+                                            }
+                                        })
+                                    },
+                                })
+                            } else {
+                                that.loading = false;
+                                uni.showModal({
+                                    title: '提示',
+                                    content: '已取消保存',
+                                    showCancel: false,
+                                })
+                            }
+                        },
+                    });
+                },
+            });
+        }, getSheraDate() {
+            let detail = this.detail
+            return {
+                title: detail.name, // 标题
+                path: "/packageCase/product/detail?id=" + detail.sa_fadid, // 分享路径
+                imageUrl: this.detail.attinfos.find(v => v.usetype == "sa_fad").url || ""// 分享图
+            };
+        }
+    },
+    onShareAppMessage(res) {
+        return this.getSheraDate()
+    },
+    onShareTimeline() {
+        return this.getSheraDate()
+    }
+}
+</script>
+
+<style lang="scss">
+.swiper {
+    width: 375px;
+    height: 231px;
+    background: #F5F5F5;
+    border-radius: 5px;
+    box-sizing: border-box;
+
+    .swiper-item {
+        position: relative;
+        width: 100%;
+        height: 100%;
+
+        .image {
+            width: 100%;
+            height: 100%;
+        }
+
+        .qrcode {
+            position: absolute;
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            top: 10px;
+            right: 10px;
+            width: 70px;
+            height: 25px;
+            background: rgba($color: #333333, $alpha: 0.5);
+            font-size: 12px;
+            color: #FFFFFF;
+
+            .iconfont {
+                margin-right: 4px;
+            }
+        }
+    }
+
+
+}
+
+.head {
+    background: #fff;
+    padding: 8px 10px 15px;
+
+    .line1 {
+        display: flex;
+        justify-content: space-between;
+        align-items: flex-end;
+
+        .left {
+            .iconfont {
+                margin-right: 4px;
+                font-size: 12px;
+            }
+
+            line-height: 17px;
+            font-size: 12px;
+            color: #999999;
+        }
+
+        .right {
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            width: 80px;
+            height: 24px;
+            border-radius: 12px;
+            border: 1px solid #CCCCCC;
+            font-family: PingFang SC, PingFang SC;
+            font-size: 12px;
+            color: #333333;
+
+            .iconfont {
+                margin-right: 5px;
+            }
+        }
+    }
+
+    .title {
+        line-height: 20px;
+        font-family: PingFang SC, PingFang SC;
+        font-weight: bold;
+        font-size: 14px;
+        color: #333333;
+        margin: 10px 0;
+    }
+
+    .subtitle {
+        line-height: 17px;
+        font-family: PingFang SC, PingFang SC;
+        font-size: 12px;
+        color: #666666;
+        margin-top: 5px;
+    }
+}
+
+.introduce {
+    background: #fff;
+    margin-top: 10px;
+    padding: 0 10px;
+
+    &-title {
+        line-height: 45px;
+        background: #FFFFFF;
+        font-family: PingFang SC, PingFang SC;
+        font-weight: bold;
+        font-size: 16px;
+        color: #333333;
+    }
+
+    &-text {
+        line-height: 20px;
+        font-family: PingFang SC, PingFang SC;
+        font-size: 14px;
+        color: #333333;
+        padding-bottom: 10px;
+    }
+}
+</style>

+ 2 - 0
pages.json

@@ -42,6 +42,8 @@
 		"root": "packageCase",
 		"pages": [{
 			"path": "imgs/detail"
+		}, {
+			"path": "product/detail"
 		}, {
 			"path": "electricAppliances/index"
 		}]

+ 2 - 0
pages/index/cloud/dataBank.vue

@@ -20,6 +20,7 @@
 export default {
     data() {
         return {
+            updatePage: true,
             appList: [],
             list: [],
             "content": {
@@ -38,6 +39,7 @@ export default {
                 console.log("未获取到授权")
             }
             this.getList(true).then(res => {
+                this.updatePage = false
                 callBack()
             })
         },

+ 17 - 10
pages/index/cloud/product.vue

@@ -17,14 +17,14 @@
             </view>
         </u-transition>
         <view class="tabs2-box" v-if="tabs2.length">
-            <v-tabs v-model="tabs2Active" field="classname" :pills="true" height="28px" pillsBorderRadius="14px"
-                pillsColor="#FFFFFF" bgColor="none" color="#FFFFFF" activeColor="#C30D23" lineScale="20px" :tabs="tabs2"
+            <v-tabs ref="tabs2" v-model="tabs2Active" field="classname" :pills="true" height="28px" pillsBorderRadius="14px"
+                pillsColor="#FFFFFF" bgColor="none" color="#FFFFFF" activeColor="#C30D23" :tabs="tabs2"
                 @change="changeClass2" />
         </view>
         <view class="tabs3-box" v-if="tabs3.length">
-            <v-tabs v-model="tabs3Active" field="classname" :pills="true" height="24px" pillsBorderRadius="12px"
+            <v-tabs ref="tabs3" v-model="tabs3Active" field="classname" :pills="true" height="24px" pillsBorderRadius="12px"
                 pillsColor="#C30D23" pillsUnColor="#eee" bgColor="none" itemMargin="0 4px 0 0" color="#333333"
-                activeColor="#FFFFFF" lineScale="10px" :tabs="tabs3" @change="changeClass3" />
+                activeColor="#FFFFFF" :tabs="tabs3" @change="changeClass3" />
         </view>
         <view class="list">
             <view class="head">
@@ -35,12 +35,13 @@
             </view>
             <My_listbox ref="List" @getlist="getList" :bottomHeight="70">
                 <view class="list-box">
-                    <view class="item" v-for="item in list" :key="item.sa_fadid" hover-class="navigator-hover">
+                    <navigator class="item" :url="'/packageCase/product/detail?id=' + item.sa_fadid" v-for="item in list"
+                        :key="item.sa_fadid" hover-class="navigator-hover">
                         <image class="image" :src="item.cover" mode="aspectFill" lazy-load="true" />
                         <view class="title u-line-1">
                             {{ item.name }}
                         </view>
-                    </view>
+                    </navigator>
                 </view>
             </My_listbox>
         </view>
@@ -52,6 +53,8 @@ export default {
     name: "product",
     data() {
         return {
+            updatePage: true,
+
             types: [],
 
             tabs2: [],
@@ -91,6 +94,7 @@ export default {
                 this.types = res.data;
                 if (res.data.length) this.changeClass1(res.data[0]).then(res => {
                     callBack()
+                    this.updatePage = false
                 })
             })
         },
@@ -108,7 +112,9 @@ export default {
             });
             this.tabs2 = item.children;
             this.tabs2Active = 0;
-
+            if (this.tabs2.length) setTimeout(() => {
+                this.$refs.tabs2.update()
+            }, 100)
             this.tabs3 = [];
             this.tabs3Active = 0;
 
@@ -132,6 +138,9 @@ export default {
             this.tabs3 = item.children || [];
             this.tabs3Active = 0;
 
+            if (this.tabs3.length) setTimeout(() => {
+                this.$refs.tabs3.update()
+            }, 100)
             this.getList(true);
         },
         changeClass3(index) {
@@ -145,7 +154,6 @@ export default {
             return new Promise((resolve, reject) => {
                 if (this.paging(this.content, init)) return resolve();
                 this.content.where.sa_fadclassids = [[this.crumbs[this.crumbs.length - 1].sa_fadclassid]];
-                console.log(this.crumbs[this.crumbs.length - 1].sa_fadclassid)
                 this.$Http.basic({
                     "id": "20240418141302",
                     content: this.content
@@ -216,8 +224,7 @@ export default {
 }
 
 .tabs2-box {
-    display: flex;
-    align-items: center;
+    padding-top: 6px;
     background: linear-gradient(90deg, #202E42 0%, #3D405F 100%);
     height: 40px;
     width: 100vw;

+ 2 - 0
pages/index/cloud/school.vue

@@ -22,6 +22,7 @@
 export default {
     data() {
         return {
+            updatePage: true,
             list: [],
             appList: [],
             "content": {
@@ -40,6 +41,7 @@ export default {
                 console.log("未获取到授权信息")
             }
             this.getList().then(res => {
+                this.updatePage = false;
                 callBack()
             })
         },

+ 1 - 1
pages/index/index.vue

@@ -33,7 +33,7 @@ export default {
 	},
 	methods: {
 		updatePageData(itemId, page) {
-			this.$refs.pages.onClick(itemId, page)
+			if (this.$refs[this.page].updatePage) this.$refs.pages.onClick(itemId, page)
 		},
 		pageChange(detail) {
 			uni.setNavigationBarTitle({

+ 2 - 1
pages/index/index/casePages/imgs.vue

@@ -47,10 +47,11 @@ export default {
             this.getList();
         },
         getList(init = false) {
-            return new Promise((resolve, reject) => {
+            return new Promise(async (resolve, reject) => {
                 if (this.paging(this.content, init)) return;
                 let content = this.content;
                 let ref = this.$refs.tabs;
+                if (ref.active == null) await ref.getTypes()
                 content.where = {
                     ...content.where,
                     ...ref.where,

+ 21 - 18
pages/index/index/casePages/tabs.vue

@@ -28,7 +28,7 @@ export default {
     },
     data() {
         return {
-            active: "",
+            active: null,
             tabs: [],
             filtrateList: [],
             widths: [0],
@@ -36,24 +36,27 @@ export default {
             where: {}
         }
     },
-    created() {
-        this.getCustomClass(this.typename).then(tabs => {
-            this.tabs = tabs;
-            if (tabs.length) {
-                this.active = tabs[0].value;
-                setTimeout(() => {
-                    uni.createSelectorQuery().in(this).selectAll(`.tabitem`).boundingClientRect(list => {
-                        let count = 0;
-                        list.forEach((v, i) => {
-                            if (i) this.widths.push(count)
-                            count += v.right;
-                        })
-                    }).exec();
-                }, 100);
-            }
-        });
-    },
     methods: {
+        getTypes() {
+            return new Promise((resolve, reject) => {
+                this.getCustomClass(this.typename).then(tabs => {
+                    this.tabs = tabs;
+                    if (tabs.length) {
+                        this.active = tabs[0].value;
+                        resolve(this.active)
+                        setTimeout(() => {
+                            uni.createSelectorQuery().in(this).selectAll(`.tabitem`).boundingClientRect(list => {
+                                let count = 0;
+                                list.forEach((v, i) => {
+                                    if (i) this.widths.push(count)
+                                    count += v.width;
+                                })
+                            }).exec();
+                        }, 100);
+                    }
+                });
+            })
+        },
         changeActive(active, index) {
             this.scrollLeft = this.widths[index]
             if (this.active == active) return;

+ 5 - 1
pages/index/index/index.vue

@@ -6,7 +6,11 @@
 
 <script>
 export default {
-
+    data() {
+        return {
+            updatePage: true,
+        }
+    },
 }
 </script>
 

+ 2 - 0
pages/index/index/myCase.vue

@@ -18,6 +18,7 @@ export default {
     components: { imgs },
     data() {
         return {
+            updatePage: true,
             tabsActive: "图库",
             tabs: ['图库', '设计美家', '实景案例', '全景720'],
             list: [],
@@ -34,6 +35,7 @@ export default {
         init(callBack) {
             if (!this.$refs[this.tabsActive].isInitialize) this.$refs[this.tabsActive].getList(true).then(res => {
                 callBack()
+                this.updatePage = false;
             })
         },
         tabsChange(tabsActive) {

+ 1 - 0
pages/index/modules/bottomSuspensionFrame.vue

@@ -66,6 +66,7 @@ export default {
     },
     methods: {
         onClick(current, name, update = false) {
+            if (name == '首页') current = 'index';
             const item = this[current].find(v => v.name == name),
                 that = this;
             if (typeof item.loading != 'boolean' || update) {

+ 5 - 0
utils/currency.js

@@ -0,0 +1,5 @@
+(function(e,g){"object"===typeof exports&&"undefined"!==typeof module?module.exports=g():"function"===typeof define&&define.amd?define(g):(e=e||self,e.currency=g())})(this,function(){function e(b,a){if(!(this instanceof e))return new e(b,a);a=Object.assign({},m,a);var d=Math.pow(10,a.precision);this.intValue=b=g(b,a);this.value=b/d;a.increment=a.increment||1/d;a.groups=a.useVedic?n:p;this.s=a;this.p=d}function g(b,a){var d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:!0;var c=a.decimal;
+var h=a.errorOnInvalid,k=a.fromCents,l=Math.pow(10,a.precision),f=b instanceof e;if(f&&k)return b.intValue;if("number"===typeof b||f)c=f?b.value:b;else if("string"===typeof b)h=new RegExp("[^-\\d"+c+"]","g"),c=new RegExp("\\"+c,"g"),c=(c=b.replace(/\((.*)\)/,"-$1").replace(h,"").replace(c,"."))||0;else{if(h)throw Error("Invalid Input");c=0}k||(c=(c*l).toFixed(4));return d?Math.round(c):c}var m={symbol:"$",separator:",",decimal:".",errorOnInvalid:!1,precision:2,pattern:"!#",negativePattern:"-!#",format:function(b,
+a){var d=a.pattern,c=a.negativePattern,h=a.symbol,k=a.separator,l=a.decimal;a=a.groups;var f=(""+b).replace(/^-/,"").split("."),q=f[0];f=f[1];return(0<=b.value?d:c).replace("!",h).replace("#",q.replace(a,"$1"+k)+(f?l+f:""))},fromCents:!1},p=/(\d)(?=(\d{3})+\b)/g,n=/(\d)(?=(\d\d)+\d\b)/g;e.prototype={add:function(b){var a=this.s,d=this.p;return e((this.intValue+g(b,a))/(a.fromCents?1:d),a)},subtract:function(b){var a=this.s,d=this.p;return e((this.intValue-g(b,a))/(a.fromCents?1:d),a)},multiply:function(b){var a=
+this.s;return e(this.intValue*b/(a.fromCents?1:Math.pow(10,a.precision)),a)},divide:function(b){var a=this.s;return e(this.intValue/g(b,a,!1),a)},distribute:function(b){var a=this.intValue,d=this.p,c=this.s,h=[],k=Math[0<=a?"floor":"ceil"](a/b),l=Math.abs(a-k*b);for(d=c.fromCents?1:d;0!==b;b--){var f=e(k/d,c);0<l--&&(f=f[0<=a?"add":"subtract"](1/d));h.push(f)}return h},dollars:function(){return~~this.value},cents:function(){return~~(this.intValue%this.p)},format:function(b){var a=this.s;return"function"===
+typeof b?b(this,a):a.format(this,Object.assign({},a,b))},toString:function(){var b=this.s,a=b.increment;return(Math.round(this.intValue/this.p/a)*a).toFixed(b.precision)},toJSON:function(){return this.value}};return e});

+ 10 - 0
utils/tool.js

@@ -152,6 +152,16 @@ function mount() {
             })
         })
     }
+
+
+    Vue.prototype.CNY = (sum, precision = 2) => {
+        const currency = require("./currency.js");
+        return currency(sum, {
+            symbol: "¥",
+            precision
+        }).format();
+    }
+
 }
 
 module.exports = {