first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
<template>
<div class="class">
<header>
<div>分类</div>
</header>
<div class="content">
<div class="list" v-for="(item,index) in list" :key='index'>
<span>{{ item.name }}</span>
<ul>
<li v-for='(item1,index1,key) in item.sub_cate' :key='index1' @tap='to_goodsDetail(item1,index,key)' >
<view v-if="!item1.show">{{item1.name}}</view>
<image v-if="item1.show" src="../../static/home/xia.png" mode="" style="height:18upx; width:30upx;"></image>
</li>
</ul>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
list: [], // 分类列表菜单
all:[],
item1:[]
}
},
created(){
this.getClass()
},
methods: {
to_goodsDetail(item,index,key) {
if(key == 8 && item.show){
let arr = this.all[item.pid]
let int = 0
this.list[index].sub_cate.pop()
for (let j in arr) {
int++
if(int>8){
this.list[index].sub_cate.push(arr[j])
}
}
}else{
uni.navigateTo({
url: '/pages/index/search??cate_id=' + item.cate_id,
})
}
},
async getClass(){
this.list = []
let res = await this.$http.class.getClass({});
for (let i in res){
let arr = res[i].sub_cate
let son = []
let int = 0
this.all[i] =[]
for (let j in arr){
int++
if(int<9){
son.push(arr[j])
}
if(int==9){
let parames = {
name:'',
pid:arr[j].pid,
show:true
}
son.push(parames)
}
this.all[i].push(arr[j])
}
res[i].sub_cate = son
this.list.push(res[i])
console.log(arr)
}
// this.classli.forEach((v,i) =>{
// let name = v.sub_cate
// for (let k in name) {
// this.namey = name[k]
// // console.log(this.namey.name)
// }
// })
// console.log(this.classli)
// console.log(this.classli[0].sub_cate)
// console.log(JSON.stringify(this.classli[0].sub_cate).name)
}
}
}
</script>
<style scoped lang="less">
@import "../../common/less/page/classify.less";
</style>

View File

@@ -0,0 +1,165 @@
<template>
<view class="con">
<!-- 搜索栏 -->
<view class="floot">
<view class="inputs" @click="input">
<img
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAYAAACN1PRVAAAC50lEQVRIS7WWz08TURDHv9OSkiYCCZqQKI0EjVExUePJsx5MvEAEPBhveJHuwtuiCKc9ISL7FrtbPejRU/EHJ/Xgv2DUBPyR+DOFAwmYdL0ISTvm2RYLlHZp4Z02b9/MZ2fmO/OWUGKZphlqbNzXycydRHQW4P0AVgHMM+MtEc143tKMaZpqz/eijSeldLsAngBwuIKXL0Q8LIT+zC9tDZZMJoOp1OIYEW7mjT8AeJTN4mUoxN/VXiYTbGfOXgDQB+C42mPGRCTSMtrb25upBF2DWZZzJw9aJSIjnV56YJpmdos0Bxoamq8RkQ0grICxmDbsC2bb8W5mmlZ1IeKLQuivKxmq95blniPiFwBCRNwjhP6knB3lxLD3K4BWAP2God33AyqcsW23n5ldAAuet9xeTjRk2/ErzPQYwFxra8tJP7kv/hhV6/n5xfcAOphxNRbTlK+Si6R0pwFWaRSxWHRqO1EVzlqWO0jEqn5PDUPrLgNzfgA4mM3i2NCQ9qka2OSkczQQwEcAPw1DaysH+wOg3vOW67fbpAWn+bqvKIEZhlZfLo0ewA21wBKJxJ6VlexvHzDnM4AjtaRRSrcD4FkfaaxdIFI6AwCUuMoLpCB9ZsxGIi2nqpF+KrX4jggnKkq/1qaW0rkOIKGauq6OD+m6roRSus9yY8fpIUKylnEF0GXDiCofW661QSylOwHwjRxwe4M4N/05YRiaRkRcNjL1Mj92VJGj+cNzAB4GAplX4XD4m+d5oWAw3AbweWb0qRqVcOoKEdW3Am66PC3LuUSEcZ+X5whz4DTAowUwMxzDiA6UAm6CKSMlmqam5h5m6gLoDMAHcs5oAeA3RPw8nf41XZg4tu2MMWPkf6QUF6J/cCOwJKya+SilcxvArSLbe0JERTFwx2AKYtvxcWYqvrHXAXcUlm+jwu9FLvHEU0Lo4t9zNSmrZFPURuuAuwLLR3iXCEPF0e0aTEGkdCeJssFdTeNWaf4LfE9oKz70n2kAAAAASUVORK5CYII="
draggable="true"
/>
<p>请输入药名/厂家</p>
</view>
<img
class="rightimg"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAArCAYAAAA65tviAAAEzElEQVRoQ+2ZW6hVVRSG/7HWGGvvE6UV2c2itOimZEQkpBGEJHUio/QhwUuRYCL1kF2eJHqK8hBJZAbRTbphYJGWhT1YPtRLKUYXwpIudhHRtNp7z7HWiLnbS6bLc99rn3OgM9/2vIzxf3OsveaYYxF6afV6/ZIoipYDuBHAeQAqvc0bwb46gL0AtmRZtr5SqXxd9E1hh5klqvo4gJUA4hEUOhRXKYCnmflBImrkC4+CtCDeATB3KFZHce5WZr4lhzkK4pxbA+D+URQ2HNc9IrLKL2yC1Gq1C+M4/goAB9Z+M7PVIrIZwD4iyobjqd01ZhYBOMs5101EjwI4I7CpaZpeWq1Wv2uCOOeeANAka7VfmflqIvqxXSFlrjezc1X1MwBnBnbXiMgDOchuANPyQTO7M0mSF8sUUZatRqOxlIheCOx9KSLTc5B/AFTzQWaeSER/luW8TDtmNkFVDwU2ayLSlYNYMHBERE4q03nZtpxzhwGcmNsVEeoN5JCInFy28zLtOecOApg4DlLmrrZjazwi7exeJ9aOR6QTu9qOzVIjYmZnq+pDAKaY2WYReY6IwvOoqVVVF5rZAiL63Tn3WFdX1/dFCOecz7iXmdlfZtZTqVR29QdaGoiZiap+AeCywOEqEekJBajqYjN7Kej7hZkvJqIjeZ9zbg6ArQB8cujbYWae1l+eVxpIo9HwCeWnhV3bJSIzwj7nnBd4Q9hHRN3MvCXvU9XnzeyucI6ZrUiSZF1fUSkNpF6vXx5F0c6Co+0icl0BZBOAeYV514rIJ0FEngJwbwF2ETNv6DiId+Cc2wjg9pYzf/28SUQ+KIBcA2BbkJB+xMxzwv9S6y7kU/NTWmt3t64QPpHttZUWEW/dzOI0TW/NsmyymX1YqVT8xey4VqvVLoiiqDuKov1xHL9JRFqc5F8czjkfubqIvE5Ef/cF0drE8Vyrvw0a8bFSH60RVx84HAcZzd3vzff/IiL+lZiXSI2ZhYj82TDmmpmxqvpSaV5cTEWE8zv7TwAmB6pni8iOMUfx30E8G8DHgbafReScJkij0XiViO4IBrcx89yxFhV/CKuqzx6uz7Wa2WtJkixsgqhqt5m9W4jARmZeQUR/jIXImNkkVX0GwPxQDxHdzMybwyK2T+RmFUT7Z9FnuQeI6ACA9+I43tjbvSNcZ2anq+oyAFcAkBI24lQAMwEkBVs7RMQ/akf/ML6QPTWOYy/6tAEcb2Lm+X09dqq6wMyeBeCdd7LtT9N0ZrVa3XMMiP9Rr9enx3H8tplN7U+Bmd2XJMnaQhQmOOfWEtGSTqpviibak6bpvEql4mvWzXbMFyvfYWYnqKr/TnKPL+f3IepzEbkyH3POzSKiV8xsSoch9gFYx8w9xQz5OJDgbRA552ZEUXR+lmWTiGh9IDLzhW4fRFV9BMDDwVU1n+a/p6w1s+IFbMisURQdyrLsBxHZ2dd3mj5Bit6cc98AuCgAXU5EdwO4qjjXzPYS0WIR2T5k1cNcMGiQRqPxMhEtGsiPmW0QkZVEFJb+B1rW9vigQVT1NjN7qx+PB4loOTO/0baqYRgYNIiZkaq+X6yKtHz6u/gSIvKpzqi0QYMEb7TVAJa2Pkp+a2ZPisj6gQ7JTtMNCaTTYtqx/y/2ZXxKzaQkWgAAAABJRU5ErkJggg=="
draggable="true"
/>
</view>
<!-- 轮播图 -->
<swiper
class="swiper"
:indicator-dots="indicatorDots"
:autoplay="autoplay"
:interval="interval"
:duration="duration"
:current="current"
:indicator-active-color="color"
>
<swiper-item v-for="(i, j) in list.banner" :key="j" @click="bann(j)">
<view class="swiper-item">
<img :src="'https://' + i.app_pic_url" draggable="true" />
</view>
</swiper-item>
</swiper>
<!-- 9宫格 -->
<view class="palaceGrid">
<view v-for="(i, j) in icons" :key="j" @click="newlist(j)">
<img :src="'https://' + i.cover_img" />
<p>{{ i.activity_name }}</p>
</view>
</view>
<!-- 通知栏 -->
<view class="notice">
<img src="/static/home/laba.png" class="noticeImg" />
<swiper :autoplay="autoplay" :interval="interval">
<swiper-item class="swp">
<p>医点医滴-中秋国庆放假通知</p>
</swiper-item>
<swiper-item class="swp">
<p>医点医滴APP上线拉!</p>
</swiper-item>
</swiper>
</view>
<!-- 新客特权 -->
<img src="/static/home/renzheng.jpg" class="prerog" />
<!-- 明星爆款 -->
<view>
<view
class="faddish"
v-for="(i, j) in list.activity_self_true"
:key="j"
@click="sous(j)"
>
<img src="/static/home/shu.png" alt="" />
<p>{{ i.activity_name }}</p>
</view>
<view>
<scroll-view scroll-x="true" class="scroll">
<view class="box" v-for="(i, j) in hot" :key="j" @click="sous(j)">
<img :src="'https://' + i.pc_thumb" alt="" />
<view class="info">
<p class="ling" v-if="i.retail_flag == 0">零</p>
<p class="hot" v-if="i.is_limit == 1">限</p>
<p class="jieshao">{{ i.goods_name }}</p>
</view>
<p class="gs">{{ i.manufacturer_name }}</p>
<p class="zhi">{{ i.spec_desc }}</p>
<p class="jiage">¥{{ i.sales_price }}</p>
</view>
</scroll-view>
</view>
<Tabs></Tabs>
</view>
</view>
</template>
<script>
import Tabs from "../../components/homeTabs";
export default {
data() {
return {
indicatorDots: true,
autoplay: true,
interval: 2000,
duration: 500,
current: 0,
color: "#fff",
//保存首页接口数据
list: [],
//保存明星爆款数据
hot: [],
//保存九宫格的数据
icons: [],
};
},
created() {
this.getIndex();
},
onLoad() {},
methods: {
//掉首页接口
async getIndex() {
let res = await this.$http.index.getIndex();
this.list = res;
// console.log("接口原数据", res);
this.icons = res.activity_icons;
// console.log("九宫格数据", this.icons);
this.list.activity_self_true.forEach((i) => {
this.hot = i.goods_list.data;
// console.log("明星爆款6条数据", i.goods_list.data);
});
},
//搜索点击跳转事件
input() {
uni.navigateTo({
url: `/pages/index/search`,
});
},
//点击明星爆款跳转到搜索页面
sous(j) {
// console.log(this.hot[j].keyword);
uni.navigateTo({
url: `/pages/index/search?key=${this.hot[j].keyword}`,
});
},
//点击九宫格跳转到搜索页面
newlist(el) {
uni.navigateTo({
url: `/pages/index/search?newlist=${this.icons[el].id}`,
});
},
//轮播图点击跳转进搜索页面
bann(el){
uni.navigateTo({
url: `/pages/index/search?banner=${this.list.banner[el].id}`,
});
},
},
components: {
Tabs
}
};
</script>
<style scoped lang="less">
@import "../../common/less/page/index.less";
</style>

View File

@@ -0,0 +1,256 @@
<template>
<view>
<!-- 头部 -->
<view class="flood">
<img
@click="back"
class="jiantou"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAfCAYAAAAFkva3AAAA9ElEQVRIS63UIW5CQRSF4f8YXFeAKHtgBU3qWlPRlWBqcDgSdoCoq6G+qhXV3Q6quWQIkCG8ee/emTd+vsxJ5hzRcMzsHvgA7oBX1Von6AeYnYx1FdYB7YGHMFaAXiR9hTAzS5G+s2jpRUcoRXVjQ5Ab80AuzAsNYhGoF4tCRawG6sRqoRusBbrCWqELNgZ0xMxsCvxmFfkHns4ViaxKwibAZwKyiytJywiUxxwFvBR9jBderUYreDNBLWDnntWCxXGsAXuXNgoOznYEHMTSZ/SCLiwDd8BzqSluzAOGsB5wIWkTxgrgn6R5FZaBW+AReJP0fgD6yKcB+KwshwAAAABJRU5ErkJggg=="
draggable="true"
/>
<view class="input">
<img
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAYAAACN1PRVAAAC50lEQVRIS7WWz08TURDHv9OSkiYCCZqQKI0EjVExUePJsx5MvEAEPBhveJHuwtuiCKc9ISL7FrtbPejRU/EHJ/Xgv2DUBPyR+DOFAwmYdL0ISTvm2RYLlHZp4Z02b9/MZ2fmO/OWUGKZphlqbNzXycydRHQW4P0AVgHMM+MtEc143tKMaZpqz/eijSeldLsAngBwuIKXL0Q8LIT+zC9tDZZMJoOp1OIYEW7mjT8AeJTN4mUoxN/VXiYTbGfOXgDQB+C42mPGRCTSMtrb25upBF2DWZZzJw9aJSIjnV56YJpmdos0Bxoamq8RkQ0grICxmDbsC2bb8W5mmlZ1IeKLQuivKxmq95blniPiFwBCRNwjhP6knB3lxLD3K4BWAP2God33AyqcsW23n5ldAAuet9xeTjRk2/ErzPQYwFxra8tJP7kv/hhV6/n5xfcAOphxNRbTlK+Si6R0pwFWaRSxWHRqO1EVzlqWO0jEqn5PDUPrLgNzfgA4mM3i2NCQ9qka2OSkczQQwEcAPw1DaysH+wOg3vOW67fbpAWn+bqvKIEZhlZfLo0ewA21wBKJxJ6VlexvHzDnM4AjtaRRSrcD4FkfaaxdIFI6AwCUuMoLpCB9ZsxGIi2nqpF+KrX4jggnKkq/1qaW0rkOIKGauq6OD+m6roRSus9yY8fpIUKylnEF0GXDiCofW661QSylOwHwjRxwe4M4N/05YRiaRkRcNjL1Mj92VJGj+cNzAB4GAplX4XD4m+d5oWAw3AbweWb0qRqVcOoKEdW3Am66PC3LuUSEcZ+X5whz4DTAowUwMxzDiA6UAm6CKSMlmqam5h5m6gLoDMAHcs5oAeA3RPw8nf41XZg4tu2MMWPkf6QUF6J/cCOwJKya+SilcxvArSLbe0JERTFwx2AKYtvxcWYqvrHXAXcUlm+jwu9FLvHEU0Lo4t9zNSmrZFPURuuAuwLLR3iXCEPF0e0aTEGkdCeJssFdTeNWaf4LfE9oKz70n2kAAAAASUVORK5CYII="
/>
<input
type="text"
placeholder="请输入药名/厂家"
v-model="value"
@keydown.enter="onenter"
@input="onInput"
/>
</view>
<img
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAArCAYAAAA65tviAAAEzElEQVRoQ+2ZW6hVVRSG/7HWGGvvE6UV2c2itOimZEQkpBGEJHUio/QhwUuRYCL1kF2eJHqK8hBJZAbRTbphYJGWhT1YPtRLKUYXwpIudhHRtNp7z7HWiLnbS6bLc99rn3OgM9/2vIzxf3OsveaYYxF6afV6/ZIoipYDuBHAeQAqvc0bwb46gL0AtmRZtr5SqXxd9E1hh5klqvo4gJUA4hEUOhRXKYCnmflBImrkC4+CtCDeATB3KFZHce5WZr4lhzkK4pxbA+D+URQ2HNc9IrLKL2yC1Gq1C+M4/goAB9Z+M7PVIrIZwD4iyobjqd01ZhYBOMs5101EjwI4I7CpaZpeWq1Wv2uCOOeeANAka7VfmflqIvqxXSFlrjezc1X1MwBnBnbXiMgDOchuANPyQTO7M0mSF8sUUZatRqOxlIheCOx9KSLTc5B/AFTzQWaeSER/luW8TDtmNkFVDwU2ayLSlYNYMHBERE4q03nZtpxzhwGcmNsVEeoN5JCInFy28zLtOecOApg4DlLmrrZjazwi7exeJ9aOR6QTu9qOzVIjYmZnq+pDAKaY2WYReY6IwvOoqVVVF5rZAiL63Tn3WFdX1/dFCOecz7iXmdlfZtZTqVR29QdaGoiZiap+AeCywOEqEekJBajqYjN7Kej7hZkvJqIjeZ9zbg6ArQB8cujbYWae1l+eVxpIo9HwCeWnhV3bJSIzwj7nnBd4Q9hHRN3MvCXvU9XnzeyucI6ZrUiSZF1fUSkNpF6vXx5F0c6Co+0icl0BZBOAeYV514rIJ0FEngJwbwF2ETNv6DiId+Cc2wjg9pYzf/28SUQ+KIBcA2BbkJB+xMxzwv9S6y7kU/NTWmt3t64QPpHttZUWEW/dzOI0TW/NsmyymX1YqVT8xey4VqvVLoiiqDuKov1xHL9JRFqc5F8czjkfubqIvE5Ef/cF0drE8Vyrvw0a8bFSH60RVx84HAcZzd3vzff/IiL+lZiXSI2ZhYj82TDmmpmxqvpSaV5cTEWE8zv7TwAmB6pni8iOMUfx30E8G8DHgbafReScJkij0XiViO4IBrcx89yxFhV/CKuqzx6uz7Wa2WtJkixsgqhqt5m9W4jARmZeQUR/jIXImNkkVX0GwPxQDxHdzMybwyK2T+RmFUT7Z9FnuQeI6ACA9+I43tjbvSNcZ2anq+oyAFcAkBI24lQAMwEkBVs7RMQ/akf/ML6QPTWOYy/6tAEcb2Lm+X09dqq6wMyeBeCdd7LtT9N0ZrVa3XMMiP9Rr9enx3H8tplN7U+Bmd2XJMnaQhQmOOfWEtGSTqpviibak6bpvEql4mvWzXbMFyvfYWYnqKr/TnKPL+f3IepzEbkyH3POzSKiV8xsSoch9gFYx8w9xQz5OJDgbRA552ZEUXR+lmWTiGh9IDLzhW4fRFV9BMDDwVU1n+a/p6w1s+IFbMisURQdyrLsBxHZ2dd3mj5Bit6cc98AuCgAXU5EdwO4qjjXzPYS0WIR2T5k1cNcMGiQRqPxMhEtGsiPmW0QkZVEFJb+B1rW9vigQVT1NjN7qx+PB4loOTO/0baqYRgYNIiZkaq+X6yKtHz6u/gSIvKpzqi0QYMEb7TVAJa2Pkp+a2ZPisj6gQ7JTtMNCaTTYtqx/y/2ZXxKzaQkWgAAAABJRU5ErkJggg=="
draggable="true"
/>
</view>
<view class="zhan"></view>
<!-- 搜索框下面的排序栏 -->
<view v-if="tanchu">
<view class="end-title tablist">
  <view @click="change(0);sort('goods_id')" :class="{ btna: btnnum == 0 }">综合</view>
 <view
:class="{ btna: btnnum == 1 }"
class="shops"
@click="
change(1);
sort('sale_num');
"
>
<p>销量</p>
<view class="shopsimgs">
<img
v-if="!xiaoliangarr"
src="/static/home/shangxia_hui.png"
alt=""
/>
<img
v-if="xiaoliangarr && xiaolianglist"
src="/static/home/down_paixu.png"
alt=""
/>
<img
v-if="xiaoliangarr && !xiaolianglist"
src="/static/home/up_paixu.png"
alt=""
/>
</view>
</view>
 <view
:class="{ btna: btnnum == 2 }"
class="shops"
@click="
change(2);
sort('price');
"
>
<p>价格</p>
<view class="shopsimgs">
<img v-if="!jiagearr" src="/static/home/shangxia_hui.png" alt="" />
<img
v-if="jiagearr && jiagelist"
src="/static/home/down_paixu.png"
alt=""
/>
<img
v-if="jiagearr && !jiagelist"
src="/static/home/up_paixu.png"
alt=""
/>
</view>
</view>
</view>
<view class="end-cont" :class="{ dis: btnnum == 0 }">
<shoplist :shop="list" class="comm"></shoplist>
</view>
<view class="end-cont" :class="{ dis: btnnum == 1 }">
<shoplist :shop="list" class="comm"></shoplist>
</view>
<view class="end-cont" :class="{ dis: btnnum == 2 }">
<shoplist :shop="list" class="comm"></shoplist>
</view>
</view>
<!-- 搜索不到内容给的提示 -->
<view class="sousuo" v-if="kon">
<img src="/static/home/nopic.png" draggable="true" />
<p>暂无数据</p>
</view>
</view>
</template>
<script>
import shoplist from "../../components/shoplist.vue";
export default {
data() {
return {
//判断搜索内容是否为空
kong: [],
//判断搜索内容标志位
kon: false,
value: "",
list: [],
//标准位,取消重复发生ajax请求
flag: false,
//保存明星爆款传来的值
hots: [],
//保存九宫格传来的id
newlist: [],
//保存轮播图传来的id
bann: [],
//tab栏切换
btnnum: 0,
//判断tab切换是否出现
tanchu: false,
//判断是否点击了销量
xiaoliangarr: false,
//判断是否点击了价格
jiagearr: false,
//销量
xiaolianglist: false,
//价格
jiagelist: false,
//排序
order: false,
sortType: null,
};
},
onLoad(el) {
this.hots = el.key;
this.newlist = el.newlist;
this.bann = el.banner;
},
created() {
//判断明星爆款是否传来了值
if (this.hots != null || this.newlist != null || this.bann != null) {
this.getsearch();
}
},
methods: {
//搜索接口
async getsearch() {
let res = await this.$http.index.search({
//根据关键字搜索
search_words: this.value || this.hots,
//根据id搜索
activity_id: this.newlist || this.bann,
});
//这里写true的原因就是首页点进来进入搜索页面tab栏切换也要打开
this.tanchu = true;
//price 是价格-----------------sale_num 是销售数量
console.log(res.data.data);
this.list = res.data.data;
//判断搜索内容是否为空
if (this.list.length == 0) {
this.kon = !this.kon;
}
},
//键盘确认键按下事件
onenter() {
if (this.value.length != 0) {
if (this.flag == true) {
this.getsearch();
this.flag = false;
this.tanchu = true;
}
} else {
uni.showToast({
title: "关键词不能为空",
icon: "none",
duration: 2000,
});
//当输入框内的值为0,清空搜索内容
this.list = "";
this.tanchu = false;
}
},
//输入框事件
onInput() {
this.flag = true;
},
//点击返回上一层
back() {
uni.navigateBack();
},
//tab栏切换事件 0-综合 1-销量 2-价格
change(e) {
//判断当前点击位置是否是综合
if (e == 0) {
}
//当前点击的位置等于销量
if (e == 1) {
this.xiaoliangarr = true;
this.jiagearr = false;
this.xiaolianglist = !this.xiaolianglist;
}
//当前点击的位置等于价格
if (e == 2) {
this.xiaoliangarr = false;
this.jiagearr = true;
this.jiagelist = !this.jiagelist;
}
this.btnnum = e;
console.log("当前点击的下标", e);
},
//实现排序
sort(type) {
this.order = !this.order; // 更改为 升序或降序
this.sortType = type;
this.list.sort(this.compare(type));
},
// 排序方法
compare(attr) {
let that = this;
return function (a, b) {
let val1 = a[attr];
let val2 = b[attr];
if (that.order) {
return val1 - val2;
} else {
return val2 - val1;
}
};
},
},
components: {
shoplist,
},
computed: {},
};
</script>
<style lang="less" scoped>
@import "../../common/less/page/search.less";
/deep/.shoplist {
margin-top: 20rpx;
}
/deep/.shoplist:first-child {
margin-top: 100rpx;
}
</style>

View File

@@ -0,0 +1,267 @@
<template>
<view class="info">
<view class="header">
<image src="/static/info/left.png" mode="" class="left"></image>
</view>
<view class="content">
<view class="shang">
<view class="tupian">
</view>
<view class="neirong">
<view class="mingzi">
<view class="left">
<image src="/static/info/xian.png" mode="" style="height:15px; width:15px;margin-right: 15px;"></image>
<!-- <image src="/static/info/re.png" mode="" style="height:15px; width:15px;margin-right:15px;" v-if='list.supplier_id<=10000'></image> -->
<view>碧生源牌常润茶</view>
</view>
<image src="/static/info/coll1.png" alt="" class='shouc'></image>
<!-- <image src="/static/info/coll2.png" alt="" class='shouc' v-if='list.is_collect==0' @click='to_change(1)'></image> -->
</view>
<view class="gongsi">
北京澳特舒尔保健品开发有限公司
</view>
<view class="shuliang">
62.5g(2.5g*20袋+12.5g)
<image src="/static/info/zheng.png" class="lingling" mode="" style="height:15px; width:15px;"></image>
<!-- <image src="/static/info/ling.png" class="lingling" mode="" style="height:15px; width:15px;" v-if='list.retail_flag == 0'></image> -->
<view class="hejian">1盒/件</view>
</view>
<view class="price">
<view class="jiage">¥60.5</view>
</view>
</view>
</view>
<view class="zhong">
<view class="">
<view class="" style="width:30%">商品名称</view>
<view>碧生源牌常润茶</view>
</view>
<view class="">
<view class="" style="width:30%">生产厂家</view>
<view>北京澳特舒尔保健品开发有限公司</view>
</view>
<view class="">
<view class="" style="width:30%">规格</view>
<view>62.5g(2.5g*20袋+12.5g)</view>
</view>
<view class="">
<view class="" style="width:30%">有效期</view>
<view>2022-07-11</view>
</view>
<view class="">
<view class="" style="width:30%">批准文号</view>
<view>Q/FATS0001-2011</view>
</view>
</view>
<view class="xia">
<view class="zhuyi">注意事项</view>
<view class="">
<view class="guiding">
1.根据国家规定,药品类商品一般情况下无质量问题不支持退货;
</view>
<view class="guiding">
2.客户在收取商品时,应当面确认商品有无破损,若发生破损,应及时联系客服;确认收货后,概不支持退换货。
</view>
</view>
</view>
</view>
<view class="footer">
<view class="the_car">
<image src="/static/info/car2.png" mode="" class="gouwuc"></image>
</view>
<view class="jiache">加入购物车</view>
<view class="ligou">立即购买</view>
</view>
</view>
</template>
<script>
export default{
data(){
return{
info: {},
sku_id: this.$route.query.id,
}
},
onShow() {
this.getInfoData();
},
onLoad(params) {
this.sku_id = params.sku_id
},
methods:{
async getInfoData() {
let res = await this.$http.index.goodsDetail({
sku_id: this.sku_id,
}
);
this.info = res;
console.log(res)
},
},
};
</script>
<style scoped lang="less">
.info{
height: 100%;
font-size: 13px;
line-height: 1.8;
.header{
height: 74px;
position: relative;
line-height: 105px;
font-size: 16px;
background: linear-gradient(to left,#6B68DC,#008BE6);
position: sticky;
top: 44px;
/* #endif */
/* #ifndef H5 */
top: 0;
/* #endif */
z-index: 999;
flex: 1;
flex-direction: column;
overflow: hidden;
.left{
position: absolute;
bottom: 14px;
left: 15px;
height: 15px;
width: 9px;
padding: 0 10px;
}
}
.content{
height: calc(100% - 114px);
overflow-y: auto;
background-color: #F2F2F2;
.shang{
background-color: #FFFFFF;
margin-bottom: 11px;
.tupian{
background-image: url(https://ydyd-develop-file.oss-cn-hangzhou.aliyuncs.com/pc_shop_thumb_url_1606785749538.png);
background-size: contain;
background-position: center center;
height: 175px;
background-repeat: no-repeat;
}
.neirong{
padding: 15px 5px;
.mingzi{
display: flex;
justify-content: space-between;
.left{
font-size: 14px;
font-weight: bold !important;
display: flex;
justify-content: space-between;
align-items: center;
image{
height: 15px;
width: 15px;
margin-right: 15px;
}
view{
font-size: 14px;
}
}
.shouc{
height: 18px;
width: 18px;
margin-right: 15px;
will-change: transform;
}
}
.gongsi{
width: 100%;
}
.shuliang{
display: flex;
align-items: center;
.lingling{
margin: 0 10px;
}
.hejian{}
}
.price{
.jiage{
color: #EB5159;
font-size: 14px;
font-weight: bold !important;
}
}
}
}
.zhong{
background: #FFFFFF;
padding: 15px 5px;
margin-bottom: 11px;
view{
display: flex;
view{
width: 30%;
}
view{
width: 70%;
}
}
}
.xia{
background: #FFFFFF;
padding: 15px 5px;
margin-bottom: 11px;
.zhuyi{
font-weight: bold !important;
}
view{
.guiding{
margin: 10px 0 10px 0;
color: #989898;
}
}
}
}
.footer{
height: 40px;
overflow: hidden;
display: flex;
align-items: center;
position: sticky;
/* #ifdef H5 */
bottom: 50px;
/* #ifndef H5 */
bottom: 0;
/* #endif */
z-index: 999;
flex: 1;
overflow: hidden;
background-color: #ffffff;
.the_car{
flex: 1;
text-align: center;
position: relative;
.gouwuc{
height: 20px;
width: 23px;
}
}
.jiache{
background-color: #EDCA4A;
line-height: 40px;
width: 38%;
color: #FFFFFF;
text-align: center;
}
.ligou{
background-color: #EB5159;
line-height: 40px;
width: 38%;
color: #FFFFFF;
text-align: center;
}
}
}
</style>

View File

@@ -0,0 +1,319 @@
<template>
<view class="content h-100">
<view class="imgaaa">
<!-- <image src="/static/login/login.png"></image> -->
<view v-if="login_flag" class="L_left">登录</view>
<view v-if="!login_flag" class="L_left">注册</view>
</view>
<view class="L_Z">
<view class="L_Z_A">
<view class="menu_items" @click="chooseMenu(index)" :class="{menu_active: menu_index==index}" v-for="(item,index) of form_menu" :key='index'>{{item.name}}</view>
</view>
</view>
<!-- 登录 -->
<view class="my_L_Z" v-if="menu_index==0">
<view class="my_phone">
<image src="/static/login/phone.png" mode="" class="phone"></image>
<input class="inputtt" type="text" cursor-spacing="20" focus placeholder="请输入手机号" v-model="phone"/>
</view>
<view class="my_key">
<image src="/static/login/suo.png" mode="" class="phone"></image>
<input class="inputtt" cursor-spacing="20" :type="is_type" placeholder="请输入密码" v-model="password"/>
<image src="/static/login/bukan.png" mode="" class="is_seen" v-if="seen==false" @tap='change_seen()'></image>
<image src="/static/login/kan.png" mode="" class="is_seen1" v-if="seen==true" @tap='change_seen()'></image>
</view>
<button class="my_login" @tap="UserLogin">登录</button>
<text class="my_forget">忘记密码?</text>
</view>
<!-- 注册 -->
<view class="my_L_Z" v-if="menu_index==1">
<view class="my_phone">
<image src="/static/login/phone.png" mode="" class="phone"></image>
<input class="inputtt" type="text" cursor-spacing="20" focus placeholder="请输入手机号" v-model="phone"/>
</view>
<view class="my_key">
<image src="/static/login/loginadd.png" mode="" class="phone" style="height: 21px;width: 27px;"></image>
<input class="inputtt" type="number" placeholder="验证码">
<view class="yanzheng" v-if="get_code==false" @click="getCode()">获取验证码</view>
<view class="yanzheng" v-else>{{count_time}}s后再次获取验证码</view>
</view>
<view class="my_key">
<image src="/static/login/suo.png" mode="" class="phone"></image>
<input class="inputtt" cursor-spacing="20" :type="is_RseenType" placeholder="请设置密码" v-model="new_password"/>
<image src="/static/login/bukan.png" mode="" class="is_seen" v-if="Rseen==false" @tap='change_Rseen()'></image>
<image src="/static/login/kan.png" mode="" class="is_seen1" v-if="Rseen==true" @tap='change_Rseen()'></image>
</view>
<view class="my_key">
<image src="/static/login/suo.png" mode="" class="phone"></image>
<input class="inputtt" cursor-spacing="20" :type="is_rseenType" placeholder="确认密码" v-model="sure_password"/>
<image src="/static/login/bukan.png" mode="" class="is_seen" v-if="rseen==false" @tap='change_rseen()'></image>
<image src="/static/login/kan.png" mode="" class="is_seen1" v-if="rseen==true" @tap='change_rseen()'></image>
</view>
<button class="my_login" @tap='UserReg'>注册</button>
<view class="agree">
<view>点击“注册”即表示您已阅读并同意</view>
<view style="color: #D82008;">《医点医滴会员服务协议》</view>
</view>
</view>
</view>
</template>
<script>
import md5 from "../../utils/md5.min.js";
export default{
data() {
return {
seen:false,
Rseen:false,
rseen:false,
login_flag:true,
is_type:'password',
is_RseenType:'password',
is_rseenType:'password',
form_menu:[{
name:'登录',
id:0
},{
name:'注册',
id:1
}],
menu_index:0,
get_code:false,
phone:'',
password:'',
new_password: '',
sure_password: '',
};
},
methods:{
// jinru(){
// uni.switchTab({
// url: '/pages/index/index'
// });
// },
// 密码内容是否可见
change_seen(){
this.seen = !this.seen
if(this.seen == true){
this.is_type = 'text'
}else{
this.is_type = 'password'
}
},
change_rseen(){
this.rseen = !this.rseen
if(this.rseen == true){
this.is_rseenType = 'text'
}else{
this.is_rseenType = 'password'
}
},
change_Rseen(){
this.Rseen = !this.Rseen
if(this.Rseen == true){
this.is_RseenType = 'text'
}else{
this.is_RseenType = 'password'
}
},
// 选择菜单(登录或者注册)
chooseMenu(index){
// 解决登录 或 注册 重复点击标题切换
if (this.menu_index != index){
this.menu_index = index;
this.login_flag = !this.login_flag
}
},
// 注册
async UserReg() {
if (!this.$util.checkPhone(this.phone)) {
this.$toast.fail("手机号必须正确");
return false;
}
if (this.new_password.length == 0) {
this.$toast.fail("密码必填");
return false;
}
if (this.sure_password.length == 0) {
this.$toast.fail("密码必填");
return false;
}
let res = await this.$http.index.reg(this.phone,this.new_password,this.sure_password);
// this.currentPage = true;
},
//登录
async UserLogin() {
if (this.phone.length == 0) {
uni.showToast({
title: '号码必填',
duration: 2000
})
return false;
}
if (this.password.length == 0) {
uni.showToast({
title: '密码必填',
duration: 2000
})
return false;
}
var now_time = (Date.parse(new Date()))/1000;
var is_sign = md5('123456' + 'test' + this.phone + md5(this.password) + now_time)
let res = await this.$http.index.login({
phone: this.phone,
password: this.password,
appid: "test",
timestamp: now_time,
sign: is_sign
});
localStorage.setItem("token", res.access_token);
setTimeout(function() {
uni.switchTab({
url: '/pages/index/index'
})
}, 500);
},
}
}
</script>
<style scoped lang="less">
.content {
line-height: 1.8;
.imgaaa{
height: 202px;
padding-top: 30px;
position: relative;
background-image: url(/static/login/login.png);
background-position: 100% 100%;
background-size: cover;
border:none;
outline: none;
-webkit-box-sizing: border-box;
.L_left{
font-size: 16px;
// margin-top:30px;
text-align: center;
color: #FFFFFF;
}
}
.L_Z{
padding: 0 32px;
font-size: 13px;
line-height: 1.8;
.L_Z_A{
display: flex;
font-size: 13px;
line-height: 1.8;
.menu_items{
margin-right:22px;
}
}
.menu_active{
color: #282828;
font-size: 16px;
border-bottom:3px solid #6B68DC;
font-weight: bold;
}
}
.my_L_Z{
padding: 50px 32px;
.my_phone{
border-bottom: 3px solid #F2F2F2;
height: 50px;
display: flex;
align-items: center;
.phone{
height: 20px;
width: 18px;
}
.inputtt{
height:20upx;
width:47upx;
border: none;
outline: none;
padding-left: 10px;
height: 100%;
width: 100%;
}
}
.my_key{
border-bottom: 3px solid #F2F2F2;
height: 50px;
display: flex;
align-items: center;
.phone{
height: 20px;
width: 18px;
}
.inputtt{
height:20upx;
width:47upx;
border: none;
outline: none;
padding-left: 10px;
height: 100%;
width: 100%;
}
.is_seen{
height: 10px;
width: 23px;
}
.is_seen1{
height:30upx;
width:47upx;
}
}
.my_login{
margin-top: 30px;
height: 34px;
color: #FFFFFF;
text-align: center;
line-height: 34px;
font-size: 15px;
background: linear-gradient(to left,#6B68DC,#008BE6);
}
.my_forget{
display: inline-block;
margin: 7px 0;
color: #6B6AD5;
border-bottom: 0.5px solid #6B6AD5;
font-size: 13px;
// line-height: 1.8;
}
.yanzheng{
color: #D82008;
font-size: 12px;
width: 50%;
text-align: right;
}
.agree {
font-size: 13px;
display: -webkit-box;
overflow: hidden;
white-space: normal !important;
text-overflow: ellipsis;
word-wrap: break-word;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical
}
}
}
</style>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,92 @@
<template>
<view>
<!-- 订单 -->
<view class="top flood">
<img
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAfCAYAAAAFkva3AAAA9ElEQVRIS63UIW5CQRSF4f8YXFeAKHtgBU3qWlPRlWBqcDgSdoCoq6G+qhXV3Q6quWQIkCG8ee/emTd+vsxJ5hzRcMzsHvgA7oBX1Von6AeYnYx1FdYB7YGHMFaAXiR9hTAzS5G+s2jpRUcoRXVjQ5Ab80AuzAsNYhGoF4tCRawG6sRqoRusBbrCWqELNgZ0xMxsCvxmFfkHns4ViaxKwibAZwKyiytJywiUxxwFvBR9jBderUYreDNBLWDnntWCxXGsAXuXNgoOznYEHMTSZ/SCLiwDd8BzqSluzAOGsB5wIWkTxgrgn6R5FZaBW+AReJP0fgD6yKcB+KwshwAAAABJRU5ErkJggg=="
@click="back" />
<p>我的订单</p>
</view>
<p class="flag"></p>
<!-- tab栏切换 -->
<view>
<view class="end-title">
  <view
@tap="change(j)"
v-for="(i, j) in navList"
:key="j"
:class="{ btna: btnnum == j }"
>{{ i.text }}</view
>
 
</view>
<view
class="end-cont"
:class="{ dis: btnnum == j }"
v-for="(i, j) in navList"
:key="j"
>{{ i.state }}</view
>
</view>
</view>
</template>
<script>
export default {
data() {
return {
btnnum: 0,
//保存的是上一个页面带来的索引
index: [],
navList: [
{
state: "全部",
text: "全部",
orderList: [],
},
{
state: "待付款",
text: "待付款",
orderList: [],
},
{
state: "待发货",
text: "待发货",
orderList: [],
},
{
state: "待收获",
text: "待收获",
orderList: [],
},
{
state: "已完成",
text: "已完成",
orderList: [],
},
],
};
},
onLoad(el) {
this.index = el.index;
},
created() {
console.log("上一页传来的下标", this.index);
this.btnnum = this.index;
},
methods: {
change(e) {
this.btnnum = e;
console.log(this.btnnum);
},
back() {
uni.navigateBack();
},
},
};
</script>
<style lang='less' scoped>
@import "../../common/less/page/meinfo.less";
</style>

View File

@@ -0,0 +1,435 @@
<template>
<view class="container">
<view class="status_bar"><!-- 这里是状态栏 --></view>
<view class="page-header">
<view :class="['title', cartList.length > 0 ? '' : 'text-center']">购物车</view>
<block v-if="cartList.length > 0">
<view class="edit" v-if="btnType === 'edit'" @click="$u.throttle(btnTool('edit'), 2000)">管理</view>
<view class="edit" v-if="btnType === 'done'" @click="$u.throttle(btnTool('done'), 2000)">完成</view>
</block>
</view>
<!-- <u-checkbox-group> -->
<view class="cart-box" v-if="cartList.length > 0">
<u-swipe-action
:show="item.show"
:disabled="swipeAction"
btn-width="160"
:index="index"
v-for="(item, index) in cartList"
:key="item._id"
@click="$u.throttle(actionClick($event, item._id), 2000)"
@open="actionOpen"
:options="options"
>
<view class="item u-border-bottom">
<u-checkbox-group @change="checkboxChange" width="36rpx">
<u-checkbox v-model="item.check" size="36" shape="circle" active-color="#007aff" class="checkbox"></u-checkbox>
</u-checkbox-group>
<view class="cart-img"><image mode="widthFix" :src="item.product.image" @click.stop="$u.throttle(gotoDetail(item.product._id), 2000)"></image></view>
<!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
<view class="title-wrap" @click.stop="$u.throttle(gotoDetail(item.product._id), 2000)">
<div class="right">
<div class="title">
<p class="hot">热</p>
<p class="effect">降脂通便胶囊</p>
</div>
<div class="firm">
<p>河南辅仁堂制药有限公司</p>
</div>
<div class="slice">
0.5*24片
</div>
<div class="case">
<p>1盒/件</p>
<p class="zero">零</p>
</div>
</div>
<view class="price">
¥
<text class="large">{{ priceInt(item.product.price) }}</text>
.{{ priceDecimal(item.product.price) }}
</view>
</view>
<u-number-box
v-model="item.product.number"
:min="1"
:max="item.product.stock"
input-width="100"
input-height="50"
@change="valChange($event, item.product._id)"
></u-number-box>
</view>
</u-swipe-action>
</view>
<view class="page-box" v-else>
<view>
<view class="emputy">
<image src="/static/order/emputy.png"></image>
<view class="explain">
您还没有相关的订单
<view class="tips">可以去看看有哪些想买的</view>
</view>
<view class="btn" @click="$u.throttle(gotoHome, 2000)">随便逛逛</view>
</view>
</view>
</view>
<!-- <u-loadmore bg-color="rgb(240, 240, 240)" :status="loadStatus" @loadmore="addRandomData"></u-loadmore> -->
<u-gap height="100" bg-color="#fff"></u-gap>
<view class="bottom" v-if="cartList.length > 0">
<u-checkbox @change="checkedAll" v-model="checked" size="40" shape="circle" active-color="#007aff" class="checkall"><span>全选</span></u-checkbox>
<text class="price fill" v-if="btnType === 'edit'">
<text class="sml">总计:</text>
¥{{ totalPrice }}
</text>
<u-button
class="button"
throttle-time="2000"
v-if="btnType === 'edit'"
@click="$u.throttle(btnClick('order'), 2000)"
size="medium"
:ripple="true"
ripple-bg-color="#FEBABD"
:customStyle="customStyle"
>
结算(
<text v-if="totalCount > 0">{{ totalCount }}</text>
<text v-else>0</text>
)件
</u-button>
<u-button
class="button"
throttle-time="2000"
v-if="btnType === 'done'"
size="medium"
:ripple="true"
ripple-bg-color="#EB5159"
shape="circle"
:customStyle="customStyle3"
@click="$u.throttle(btnClick('collect'), 2000)"
>
移入收藏夹
</u-button>
<u-button
class="button"
throttle-time="2000"
v-if="btnType === 'done'"
size="medium"
:ripple="true"
ripple-bg-color="#EB5159"
shape="circle"
:customStyle="customStyle2"
@click="$u.throttle(btnClick('del'), 2000)"
>
删除
</u-button>
</view>
<u-modal
v-model="showModal"
:title="title"
:content="content"
:title-style="titleStyle"
:content-style="contentStyle"
:confirm-style="confirmStyle"
:show-cancel-button="true"
@confirm="confirm"
></u-modal>
<u-toast ref="uToast" />
</view>
</template>
<script>
import sortdata from 'static/data/cartData.js';
export default {
data() {
return {
loadStatus: 'loadmore',
cartList: [], //购物车列表
showModal: false, //modal弹窗
title: '提示', //弹窗标题
content: '确认删除商品?', //弹窗内容
delId: '', //删除id,
options: [
{
text: '删除',
style: {
backgroundColor: '#FD013E'
}
}
], //u-swipe-action样式
btnType: 'edit', //按钮类型
checked: false, //是否全选
swipeAction: false, //是否禁止滑动
// u-button样式
customStyle: {
color: '#fff',
backgroundColor: '#eb5159',
margin: '0',
padding: '0 20rpx',
width: '260rpx',
height: '100%',
fontSize: '32rpx',
},
customStyle2: {
color: '#eb5159',
backgroundColor: 'rgba(0,0,0, 0)',
margin: '0 30rpx',
padding: '0 10rpx',
border: 'none',
width: '150rpx',
height: '60rpx',
fontSize: '32rpx'
},
customStyle3:{
border: '0.5px solid #EDCA4A',
height: '30px',
width:'99px',
color: '#EDCA4A',
margin: '0 22px 0 30px',
},
// 模态窗样式
titleStyle: {
fontSize: '36rpx'
},
contentStyle: {
fontSize: '36rpx'
},
confirmStyle: {
color: '#fff',
backgroundColor: '#FD013E'
}
};
},
onShow() {
this.checked = false;
this.getCart();
console.log(this.cartList);
},
computed: {
// 价格合计
totalPrice() {
let sumPrice = 0,
items = this.cartList;
items.forEach(val => {
let priceVal = parseFloat(val.product.price),
salesVal = parseFloat(val.product.number);
if (val.check) {
sumPrice += priceVal * salesVal;
}
});
// sumPrice = sumPrice == 0 ? 0 : sumPrice.toFixed(2);
let tofixNum = sumPrice.toFixed(2);
return parseFloat(tofixNum);
},
// 数量统计
totalCount() {
let totalNumber = 0,
items = this.cartList;
items.forEach(val => {
if (val.check) {
totalNumber += val.number;
}
});
return totalNumber;
},
// 价格整数
priceInt() {
return val => {
let priceStr = val.toString();
if (priceStr != parseInt(priceStr)) {
return priceStr.split('.')[0];
} else {
return priceStr;
}
};
},
// 价格小数
priceDecimal() {
return val => {
let priceStr = val.toString();
if (priceStr != parseInt(priceStr)) {
return priceStr.split('.')[1];
} else {
return '00';
}
};
}
},
methods: {
// 购物车列表
getCart() {
const resData = sortdata.cartData;
resData.forEach(val => {
val.show = false;
val.check = false;
});
this.cartList = resData;
},
gotoHome() {
uni.switchTab({
url: '/pages/tabbar/home/home'
});
},
// 管理按钮
btnTool(type) {
switch (type) {
case 'edit':
this.btnType = 'done';
this.swipeAction = true;
let items = this.cartList;
items.forEach(val => {
val.show = false;
});
break;
case 'done':
this.btnType = 'edit';
this.swipeAction = false;
break;
}
},
// 删除
actionClick(index, del) {
this.showModal = true;
this.delId = del;
},
// 删除确认
confirm() {
let _self = this;
let delArr = [],
type = _self.btnType,
items = _self.cartList;
if (type === 'edit') {
delArr.push(_self.delId);
} else {
items.forEach(val => {
if (val.check) {
delArr.push(val._id);
}
});
_self.btnType = 'edit';
}
// 为了模拟清空购物车
if (delArr.length == items.length) {
_self.cartList = [];
}
_self.$refs.uToast.show({
title: '删除了id为' + delArr + '的商品',
icon: false
});
},
// 如果打开一个的时候,不需要关闭其他,则无需实现本方法
actionOpen(index) {
// 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
// 原本为'false',再次设置为'false'会无效
let items = this.cartList;
items[index].show = true;
items.forEach((val, idx) => {
if (index != idx) {
items[idx].show = false;
}
});
},
// 跳转详情
gotoDetail(id) {
console.log(id);
uni.navigateTo({
url: '/pages/info/info'
})
},
// 选中商品
checkboxChange(e) {
let items = this.cartList;
let checkedArr = [];
items.forEach(val => {
if (val.check) {
checkedArr.push(val);
}
});
let len = checkedArr.length;
// 如果选择的数组中有值,并且长度等于列表长度,就是全选
if (len > 0 && len == items.length) {
this.checked = true;
} else {
this.checked = false;
}
},
// 数量增减
valChange(e, id) {
// console.log(e, id);
},
// 全选
checkedAll() {
this.checked = !this.checked;
let flag = this.checked,
items = this.cartList;
items.forEach(val => {
if (flag) {
val.check = true;
} else {
val.check = false;
}
});
},
// 结算
btnClick(type) {
let _self = this;
switch (type) {
case 'order':
let items = _self.cartList;
let checkedArr = [];
items.forEach(val => {
if (val.check) {
checkedArr.push(val._id);
}
});
let shopIds = checkedArr.toString();
if (!shopIds) {
_self.$refs.uToast.show({
title: '请选择要结算的商品!',
icon: false
});
return;
}
console.log(shopIds);
// uni.navigateTo({
// url: '/pages/order/createOrder?cartId=' + shopIds
// });
break;
case 'del':
if (!_self.totalCount) {
_self.$refs.uToast.show({
title: '请选择要删除的商品!',
icon: false
});
return;
}
_self.showModal = true;
break;
case 'collect':
if (!_self.totalCount) {
_self.$refs.uToast.show({
title: '请选择要收藏的商品!',
icon: false
});
return;
} else if(_self.totalCount) {
_self.$refs.uToast.show({
title: '收藏成功!',
icon: false
})
break;
}
}
}
}
};
</script>
<style lang="scss" scoped>
// 状态栏占位
@import "../../common/less/page/shop";
</style>