index.vue 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. <template>
  2. <!-- 商品列表 -->
  3. <view :style="colorStyle">
  4. <view class='productList'>
  5. <view class='search bg-color acea-row row-between-wrapper'>
  6. <view v-if="promotions_type" class="iconfont icon-fanhui2 fanhui" @click="goCart"></view>
  7. <view class="home acea-row row-center-wrapper" @click="moreNav" v-else>
  8. <!-- <view class="iconfont icon-fanhui2"></view>
  9. <view class="line"></view> -->
  10. <view class="iconfont icon-gengduo2"></view>
  11. </view>
  12. <view class='input acea-row row-between-wrapper' :class="promotions_type?'on':''"><text
  13. class='iconfont icon-sousuo'></text>
  14. <input placeholder='搜索商品名称' placeholder-class='placeholder' confirm-type='search' name="search"
  15. :value='where.keyword' @confirm="searchSubmit"></input>
  16. </view>
  17. <view class='iconfont' v-if="!promotions_type"
  18. :class='is_switch==true?"icon-pailie":"icon-tupianpailie"' @click='Changswitch'>
  19. </view>
  20. </view>
  21. <view class='nav acea-row row-middle row-around'>
  22. <view class='item line1' :class='title ? "font-num":""' @click='set_where(1)'>{{title ? title:'默认'}}
  23. </view>
  24. <view class='item' @click='set_where(2)'>
  25. 价格
  26. <image v-if="price==1" src='../../../static/images/up.png'></image>
  27. <image v-else-if="price==2" src='../../../static/images/down.png'></image>
  28. <image v-else src='../../../static/images/horn.png'></image>
  29. </view>
  30. <view class='item' @click='set_where(3)'>
  31. 销量
  32. <image v-if="stock==1" src='../../../static/images/up.png'></image>
  33. <image v-else-if="stock==2" src='../../../static/images/down.png'></image>
  34. <image v-else src='../../../static/images/horn.png'></image>
  35. </view>
  36. <!-- down -->
  37. <!-- <view class='item' :class='nows ? "font-color":""' @click='set_where(4)'>新品</view> -->
  38. <view class='item' v-if="brandList.length" :class="{clored:brandArray.length>0}" @click='set_brand'>品牌
  39. <image src='../static/xiala.png'></image>
  40. </view>
  41. <homeList :navH="navH" :goodList="goodList" :currentPage="currentPage" :sysHeight="sysHeight"
  42. :goodsShow="true"></homeList>
  43. </view>
  44. <view class='list acea-row row-between-wrapper' :class='is_switch==true?"":"on"' v-if="is_switch==false">
  45. <view class="title" v-if="promotionsInfo.title"><text class="label">{{promotionsInfo.title}}</text>{{promotionsInfo.desc}}</view>
  46. <view class='item' :class='is_switch==true?"":"on"' hover-class='none'
  47. v-for="(item,index) in productList" :key="index" @click="godDetail(item)">
  48. <view class='pictrue' :class='is_switch==true?"":"on"'>
  49. <image :src='item.image' :class='is_switch==true?"":"on"'></image>
  50. <view class="masks acea-row row-center-wrapper" v-if="item.stock<=0">
  51. <view class="bg">
  52. <view>暂时</view>
  53. <view>售罄</view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class='text' :class='is_switch==true?"":"on"'>
  58. <view class="nameCon">
  59. <view class='name line1'>{{item.store_name}}</view>
  60. <text class="label"
  61. v-if="item.activity && item.activity.type === '1' && !promotions_type">秒杀</text>
  62. <text class="label"
  63. v-if="item.activity && item.activity.type === '2' && !promotions_type">砍价</text>
  64. <text class="label"
  65. v-if="item.activity && item.activity.type === '3' && !promotions_type">拼团</text>
  66. <text class="label" v-if="item.promotions.title">{{item.promotions.title}}</text>
  67. </view>
  68. <view class="vip acea-row row-middle on">
  69. <view class='money font-color' :class='is_switch==true?"":"on"'>¥<text
  70. class='num'>{{item.price}}</text></view>
  71. <view class='vip-money acea-row row-middle' v-if="item.vip_price && item.vip_price > 0">
  72. <view>¥{{item.vip_price}}</view>
  73. <view class="icon on" v-if="item.price_type && item.price_type == 'member'"><text
  74. class="iconfont icon-huangguan4"></text>SVIP</view>
  75. <view class="icon" v-if="item.price_type && item.price_type == 'level'"><text
  76. class="iconfont icon-dengjitubiao"></text>{{item.level_name}}</view>
  77. </view>
  78. </view>
  79. <view class='sales acea-row row-between-wrapper'>
  80. <view class="acea-row">
  81. <view>已售{{item.sales}}{{item.unit_name || '件'}}</view>
  82. <view class="score">评分 {{item.star}}</view>
  83. </view>
  84. <view v-if="promotions_type && item.product_type==0 && !item.custom_form.length"
  85. class="icon acea-row row-center-wrapper" @click.stop="joinCart(item)">
  86. <text class="iconfont icon-gouwuche"></text>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <view class='loadingicon acea-row row-center-wrapper' v-if='productList.length > 0'>
  92. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  93. </view>
  94. <view class="height-add" v-if="productList.length>3"></view>
  95. <view class="footer acea-row row-between-wrapper" v-if="promotions_type">
  96. <view class="acea-row row-middle">
  97. <view class="icon">
  98. <text class="iconfont icon-pinzhongqiquan"></text>
  99. <view class="num acea-row row-center-wrapper" v-if="totalNum>0">{{totalNum}}</view>
  100. </view>
  101. <view class="right">
  102. <view class="num">小计:<text class="money">¥{{totalPrice || 0}}</text></view>
  103. <view v-if="this.promotions_type != 4">
  104. <view v-if="promotionsInfo.differ_threshold>0">
  105. 再买{{promotionsInfo.differ_threshold}}{{promotionsInfo.threshold_type==1?'元':'件'}}<text
  106. v-if="promotionsInfo.differ_price || promotionsInfo.differ_discount">,
  107. <text v-if="promotionsInfo.differ_price">可减{{promotionsInfo.differ_price}}元</text>
  108. <text v-else>可打{{parseFloat(promotionsInfo.differ_discount)/10}}折</text>
  109. </text>
  110. </view>
  111. <view v-else>
  112. <text v-if="promotionsInfo.reach_threshold">已购满{{promotionsInfo.reach_threshold}}{{promotionsInfo.threshold_type==1?'元':'件'}},</text>已减{{promotionsInfo.sum_promotions_price}}元
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <view class="bnt" @click="goCart">去购物车</view>
  118. </view>
  119. </view>
  120. <view class="list waterList" v-else>
  121. <waterfallsFlow ref="waterfallsFlow" :list="productList" @wapper-lick="godDetail">
  122. <!-- #ifdef MP-WEIXIN -->
  123. <view v-for="(item, index) of productList" :key="index" slot="slot{{index}}">
  124. <view class="waterfalls">
  125. <view class='name line2'>{{item.store_name}}</view>
  126. <span class="label"
  127. v-if="item.activity && item.activity.type === '1' && !promotions_type">秒杀</span>
  128. <span class="label"
  129. v-if="item.activity && item.activity.type === '2' && !promotions_type">砍价</span>
  130. <span class="label"
  131. v-if="item.activity && item.activity.type === '3' && !promotions_type">拼团</span>
  132. <text class="label" v-if="item.promotions.title">{{item.promotions.title}}</text>
  133. <view class="vip acea-row row-middle">
  134. <view class='money font-color'>
  135. ¥<text class='num'>{{item.price.toString().split(".")[0]}}</text>
  136. <text class='nums'
  137. v-if="item.price.toString().split('.').length>1">.{{item.price.toString().split(".")[1]}}</text>
  138. </view>
  139. <view class='vip-money acea-row row-middle' v-if="item.vip_price && item.vip_price > 0">
  140. <view>¥{{item.vip_price}}</view>
  141. <!-- <image src='../../static/images/vip.png' v-if="item.price_type == 'member'"></image> -->
  142. <view class="icon on" v-if="item.price_type && item.price_type == 'member'"><text
  143. class="iconfont icon-huangguan4"></text>SVIP</view>
  144. <view class="icon" v-if="item.price_type && item.price_type == 'level'"><text
  145. class="iconfont icon-dengjitubiao"></text>{{item.level_name}}</view>
  146. </view>
  147. </view>
  148. <view class='vip acea-row row-between-wrapper'>
  149. <view>已售{{item.sales}}{{item.unit_name || '件'}}</view>
  150. <view>评分 {{item.star}}</view>
  151. </view>
  152. </view>
  153. </view>
  154. <!-- #endif -->
  155. <!-- #ifndef MP-WEIXIN -->
  156. <template v-slot:default="item">
  157. <view class="waterfalls">
  158. <view class='name line2'>{{item.store_name}}</view>
  159. <span class="label"
  160. v-if="item.activity && item.activity.type === '1' && !promotions_type">秒杀</span>
  161. <span class="label"
  162. v-if="item.activity && item.activity.type === '2' && !promotions_type">砍价</span>
  163. <span class="label"
  164. v-if="item.activity && item.activity.type === '3' && !promotions_type">拼团</span>
  165. <text class="label" v-if="item.promotions.title">{{item.promotions.title}}</text>
  166. <view class="vip acea-row row-middle">
  167. <view class='money font-color'>
  168. ¥<text class='num'>{{item.price.toString().split(".")[0]}}</text>
  169. <text class='nums'
  170. v-if="item.price.toString().split('.').length>1">.{{item.price.toString().split(".")[1]}}</text>
  171. </view>
  172. <view class='vip-money acea-row row-middle' v-if="item.vip_price && item.vip_price > 0">
  173. <view>¥{{item.vip_price}}</view>
  174. <view class="icon on" v-if="item.price_type && item.price_type == 'member'"><text
  175. class="iconfont icon-huangguan4"></text>SVIP</view>
  176. <view class="icon" v-if="item.price_type && item.price_type == 'level'"><text
  177. class="iconfont icon-v"></text>{{item.level_name}}</view>
  178. </view>
  179. </view>
  180. <view class='vip acea-row row-between-wrapper'>
  181. <view>已售{{item.sales}}{{item.unit_name || '件'}}</view>
  182. <view>评分 {{item.star}}</view>
  183. </view>
  184. </view>
  185. </template>
  186. <!-- #endif -->
  187. </waterfallsFlow>
  188. <view class='loadingicon acea-row row-center-wrapper' v-if='productList.length > 0'>
  189. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  190. </view>
  191. </view>
  192. </view>
  193. <view class='noCommodity' v-if="productList.length==0 && where.page > 1">
  194. <view class='emptyBox'>
  195. <image :src="imgHost + '/statics/images/no-thing.png'"></image>
  196. <view class="tips">暂无商品,去看点别的吧</view>
  197. </view>
  198. <recommend :hostProduct="hostProduct"></recommend>
  199. </view>
  200. <productWindow :attr="attr" :isShow='1' :iSplus='1' :iScart='1' :storeInfo='storeInfo' @myevent="onMyEvent"
  201. @ChangeAttr="ChangeAttr" @ChangeCartNum="ChangeCartNum" @attrVal="attrVal" @iptCartNum="iptCartNum"
  202. @goCat="goCat" id='product-window' :is_vip="is_vip"></productWindow>
  203. <home v-if="navigation"></home>
  204. <view class="mask" @touchmove.prevent :hidden="brandtip === false" @click="closeBrand"></view>
  205. <view class="selectbrand" :class="brandtip === true ? 'on' : ''">
  206. <view class="box">
  207. <view class="selet">
  208. <view class="seletbox acea-row row-center-wrapper"
  209. :class="{seleton:brandArray.indexOf(item.id) != -1}" v-for="(item,index) in brandList"
  210. :key="index" @click="seletBrand(item.id)">{{item.brand_name}}</view>
  211. </view>
  212. <view class="btn">
  213. <div class="sambox reset" @click="brandReset">重置</div>
  214. <div class="sambox ok" @click="brandOk">确定</div>
  215. </view>
  216. </view>
  217. </view>
  218. <!-- #ifdef MP -->
  219. <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize>
  220. <!-- #endif -->
  221. </view>
  222. </template>
  223. <script>
  224. import home from '@/components/home';
  225. import homeList from '@/components/homeList'
  226. import productWindow from '@/components/productWindow';
  227. import waterfallsFlow from "@/components/maramlee-waterfalls-flow/maramlee-waterfalls-flow.vue";
  228. import {
  229. getProductslist,
  230. getProductHot,
  231. brand,
  232. getAttr,
  233. postCartAdd
  234. } from '@/api/store.js';
  235. import {
  236. toLogin
  237. } from '@/libs/login.js';
  238. import recommend from '@/components/recommend';
  239. import {
  240. mapGetters
  241. } from "vuex";
  242. import {
  243. goShopDetail
  244. } from '@/libs/order.js';
  245. import {
  246. getCartList,
  247. getCartCounts
  248. } from '@/api/order.js';
  249. import colors from '@/mixins/color.js';
  250. import {HTTP_REQUEST_URL} from '@/config/app';
  251. export default {
  252. computed: mapGetters(['uid', 'isLogin']),
  253. components: {
  254. recommend,
  255. home,
  256. homeList,
  257. waterfallsFlow,
  258. productWindow
  259. },
  260. mixins: [colors],
  261. data() {
  262. return {
  263. id: 0,
  264. productValue: [], //系统属性
  265. is_vip: 0, //是否是会员
  266. attr: {
  267. cartAttr: false,
  268. productAttr: [],
  269. productSelect: {}
  270. },
  271. attrValue: '', //已选属性
  272. navH: 22,
  273. sysHeight: 0,
  274. goodList: true,
  275. currentPage: false,
  276. brandtip: false, //品牌弹窗
  277. brandArray: [],
  278. productList: [],
  279. is_switch: true,
  280. where: {
  281. sid: 0,
  282. keyword: '',
  283. priceOrder: '',
  284. salesOrder: '',
  285. news: 0,
  286. page: 1,
  287. limit: 20,
  288. cid: 0,
  289. brand_id: [],
  290. promotions_id: 0
  291. },
  292. price: 0,
  293. stock: 0,
  294. nows: false,
  295. loadend: false,
  296. loading: false,
  297. loadTitle: '加载更多',
  298. title: '',
  299. hostProduct: [],
  300. hotPage: 1,
  301. hotLimit: 10,
  302. hotScroll: false,
  303. brandList: [],
  304. storeInfo: {},
  305. promotions_type: 0,
  306. totalPrice: 0,
  307. promotionsInfo: {},
  308. totalNum: 0,
  309. imgHost:HTTP_REQUEST_URL,
  310. isShowAuth: false
  311. };
  312. },
  313. onLoad: function(options) {
  314. this.where.cid = options.cid || 0;
  315. this.$set(this.where, 'sid', options.sid || 0);
  316. this.title = options.title || '';
  317. this.$set(this.where, 'keyword', options.searchValue || '');
  318. this.$set(this.where, 'productId', options.productId || '');
  319. if (options.promotions_type) {
  320. this.promotions_type = options.promotions_type;
  321. this.where.promotions_id = options.promotions_id;
  322. if (options.promotions_type) {
  323. this.is_switch = false
  324. }
  325. }
  326. this.get_product_list();
  327. this.getBrand();
  328. },
  329. onShow() {
  330. uni.removeStorageSync('form_type_cart');
  331. if (this.isLogin && !this.is_switch) {
  332. this.getCartList();
  333. this.getCartNum();
  334. }
  335. },
  336. methods: {
  337. getIsLogin(){
  338. // #ifndef MP
  339. toLogin()
  340. // #endif
  341. // #ifdef MP
  342. this.isShowAuth = true;
  343. // #endif
  344. },
  345. onLoadFun(){
  346. if (!this.is_switch) {
  347. this.getCartList();
  348. this.getCartNum();
  349. }
  350. this.isShowAuth = false
  351. },
  352. // 授权关闭
  353. authColse: function(e) {
  354. this.isShowAuth = e
  355. },
  356. getCartNum() {
  357. let id = uni.getStorageSync('user_store_id') || 0;
  358. getCartCounts(0,id).then(res => {
  359. this.totalNum = res.data.count;
  360. }).catch(err => {
  361. return this.$util.Tips({
  362. title: err
  363. });
  364. })
  365. },
  366. getCartList() {
  367. let truePrice = 0;
  368. getCartList().then(res => {
  369. let data = res.data,
  370. valid = res.data.valid;
  371. valid.forEach(item => {
  372. item.promotions.forEach(z => {
  373. if (this.where.promotions_id == z.id) {
  374. this.promotionsInfo = z;
  375. }
  376. })
  377. item.cart.forEach(j => {
  378. truePrice = this.$util.$h.Add(truePrice, this.$util.$h.Mul(j.truePrice, j.cart_num));
  379. })
  380. })
  381. this.totalPrice = this.$util.$h.Sub(truePrice, data.deduction.coupon_price)
  382. }).catch(err => {
  383. return this.$util.Tips({
  384. title: err
  385. });
  386. })
  387. },
  388. goCart() {
  389. uni.switchTab({
  390. url: '/pages/order_addcart/order_addcart'
  391. })
  392. },
  393. /*
  394. * 加入购物车
  395. */
  396. goCat: function(news) {
  397. let that = this,
  398. productSelect = that.productValue[this.attrValue];
  399. //如果有属性,没有选择,提示用户选择
  400. if (that.attr.productAttr.length && productSelect === undefined)
  401. return that.$util.Tips({
  402. title: '产品库存不足,请选择其它属性'
  403. });
  404. if (that.attr.productSelect.cart_num <= 0) {
  405. that.attr.productSelect.cart_num = 1
  406. return that.$util.Tips({
  407. title: '请先选择属性'
  408. });
  409. }
  410. let q = {
  411. productId: that.id,
  412. cartNum: that.attr.productSelect.cart_num,
  413. new: 0,
  414. uniqueId: that.attr.productSelect !== undefined ? that.attr.productSelect.unique : ''
  415. };
  416. postCartAdd(q)
  417. .then(function(res) {
  418. that.isOpen = false;
  419. that.attr.cartAttr = false;
  420. if (news) {
  421. uni.navigateTo({
  422. url: '/pages/goods/order_confirm/index?new=1&cartId=' + res.data.cartId
  423. });
  424. } else {
  425. that.$util.Tips({
  426. title: '添加购物车成功'
  427. });
  428. }
  429. that.getCartNum();
  430. that.getCartList();
  431. })
  432. .catch(err => {
  433. that.isOpen = false;
  434. return that.$util.Tips({
  435. title: err
  436. });
  437. });
  438. },
  439. /**
  440. * 打开属性加入购物车
  441. *
  442. */
  443. joinCart: function(item) {
  444. //是否登录
  445. if (this.isLogin === false) {
  446. this.getIsLogin();
  447. } else {
  448. uni.showLoading({
  449. title: '加载中'
  450. });
  451. this.getAttrs(item.id);
  452. this.$set(this, 'id', item.id);
  453. this.$set(this.attr, 'cartAttr', true);
  454. }
  455. },
  456. // 商品详情接口;
  457. getAttrs(id) {
  458. let that = this;
  459. getAttr(id, 0).then(res => {
  460. uni.hideLoading();
  461. that.$set(that.attr, 'productAttr', res.data.productAttr);
  462. that.$set(that, 'productValue', res.data.productValue);
  463. that.$set(that, 'is_vip', res.data.storeInfo.is_vip);
  464. that.$set(that, 'storeInfo', res.data.storeInfo);
  465. that.DefaultSelect();
  466. })
  467. },
  468. /**
  469. * 默认选中属性
  470. *
  471. */
  472. DefaultSelect: function() {
  473. let productAttr = this.attr.productAttr;
  474. let value = [];
  475. for (var key in this.productValue) {
  476. if (this.productValue[key].stock > 0) {
  477. value = this.attr.productAttr.length ? key.split(',') : [];
  478. break;
  479. }
  480. }
  481. for (let i = 0; i < productAttr.length; i++) {
  482. this.$set(productAttr[i], 'index', value[i]);
  483. }
  484. //sort();排序函数:数字-英文-汉字;
  485. let productSelect = this.productValue[value.join(',')];
  486. if (productSelect && productAttr.length) {
  487. this.$set(this.attr.productSelect, 'store_name', this.storeInfo.store_name);
  488. this.$set(this.attr.productSelect, 'image', productSelect.image);
  489. this.$set(this.attr.productSelect, 'price', productSelect.price);
  490. this.$set(this.attr.productSelect, 'stock', productSelect.stock);
  491. this.$set(this.attr.productSelect, 'unique', productSelect.unique);
  492. this.$set(this.attr.productSelect, 'cart_num', 1);
  493. this.$set(this, 'attrValue', value.join(','));
  494. this.$set(this.attr.productSelect, 'vip_price', productSelect.vip_price);
  495. } else if (!productSelect && productAttr.length) {
  496. this.$set(this.attr.productSelect, 'store_name', this.storeInfo.store_name);
  497. this.$set(this.attr.productSelect, 'image', this.storeInfo.image);
  498. this.$set(this.attr.productSelect, 'price', this.storeInfo.price);
  499. this.$set(this.attr.productSelect, 'stock', 0);
  500. this.$set(this.attr.productSelect, 'unique', '');
  501. this.$set(this.attr.productSelect, 'cart_num', 0);
  502. this.$set(this.attr.productSelect, 'vip_price', this.storeInfo.vip_price);
  503. this.$set(this, 'attrValue', '');
  504. } else if (!productSelect && !productAttr.length) {
  505. this.$set(this.attr.productSelect, 'store_name', this.storeInfo.store_name);
  506. this.$set(this.attr.productSelect, 'image', this.storeInfo.image);
  507. this.$set(this.attr.productSelect, 'price', this.storeInfo.price);
  508. this.$set(this.attr.productSelect, 'stock', this.storeInfo.stock);
  509. this.$set(this.attr.productSelect, 'unique', this.storeInfo.unique || '');
  510. this.$set(this.attr.productSelect, 'cart_num', 1);
  511. this.$set(this.attr.productSelect, 'vip_price', this.storeInfo.vip_price);
  512. this.$set(this, 'attrValue', '');
  513. }
  514. },
  515. /**
  516. * 购物车手动填写
  517. *
  518. */
  519. iptCartNum: function(e) {
  520. this.$set(this.attr.productSelect, 'cart_num', e);
  521. },
  522. attrVal(val) {
  523. this.$set(this.attr.productAttr[val.indexw], 'index', this.attr.productAttr[val.indexw].attr_values[val
  524. .indexn]);
  525. },
  526. onMyEvent: function() {
  527. this.$set(this.attr, 'cartAttr', false);
  528. },
  529. /**
  530. * 属性变动赋值
  531. *
  532. */
  533. ChangeAttr: function(res) {
  534. let productSelect = this.productValue[res];
  535. if (productSelect && productSelect.stock > 0) {
  536. this.$set(this.attr.productSelect, "image", productSelect.image);
  537. this.$set(this.attr.productSelect, "price", productSelect.price);
  538. this.$set(this.attr.productSelect, "stock", productSelect.stock);
  539. this.$set(this.attr.productSelect, "unique", productSelect.unique);
  540. this.$set(this.attr.productSelect, 'vip_price', productSelect.vip_price);
  541. this.$set(this.attr.productSelect, "cart_num", 1);
  542. this.$set(this, "attrValue", res);
  543. } else if (productSelect && productSelect.stock == 0) {
  544. this.$set(this.attr.productSelect, "image", productSelect.image);
  545. this.$set(this.attr.productSelect, "price", productSelect.price);
  546. this.$set(this.attr.productSelect, "stock", 0);
  547. this.$set(this.attr.productSelect, "unique", "");
  548. this.$set(this.attr.productSelect, 'vip_price', productSelect.vip_price);
  549. this.$set(this.attr.productSelect, "cart_num", 0);
  550. this.$set(this, "attrValue", "");
  551. } else {
  552. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  553. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  554. this.$set(this.attr.productSelect, "stock", 0);
  555. this.$set(this.attr.productSelect, "unique", "");
  556. this.$set(this.attr.productSelect, 'vip_price', this.storeInfo.vip_price);
  557. this.$set(this.attr.productSelect, "cart_num", 0);
  558. this.$set(this, "attrValue", "");
  559. }
  560. },
  561. /**
  562. * 购物车数量加和数量减
  563. *
  564. */
  565. ChangeCartNum: function(changeValue) {
  566. //changeValue:是否 加|减
  567. //获取当前变动属性
  568. let productSelect = this.productValue[this.attrValue];
  569. //如果没有属性,赋值给商品默认库存
  570. if (productSelect === undefined && !this.attr.productAttr.length) productSelect = this.attr
  571. .productSelect;
  572. //无属性值即库存为0;不存在加减;
  573. if (productSelect === undefined) return;
  574. let stock = productSelect.stock || 0;
  575. let num = this.attr.productSelect;
  576. if (changeValue) {
  577. num.cart_num++;
  578. if (num.cart_num > stock) {
  579. this.$set(this.attr.productSelect, 'cart_num', stock ? stock : 1);
  580. this.$set(this, 'cart_num', stock ? stock : 1);
  581. }
  582. } else {
  583. num.cart_num--;
  584. if (num.cart_num < 1) {
  585. this.$set(this.attr.productSelect, 'cart_num', 1);
  586. this.$set(this, 'cart_num', 1);
  587. }
  588. }
  589. },
  590. moreNav() {
  591. this.currentPage = !this.currentPage
  592. },
  593. // 品牌列表
  594. getBrand() {
  595. brand(this.where).then(res => {
  596. this.brandList = res.data
  597. }).catch(err => {
  598. return this.$util.Tips({
  599. title: err.msg
  600. });
  601. })
  602. },
  603. //打开品牌弹窗
  604. set_brand() {
  605. this.brandtip = true
  606. this.currentPage = false
  607. },
  608. //关闭品牌/新品弹窗
  609. closeBrand() {
  610. this.brandtip = false
  611. },
  612. // 品牌选择
  613. seletBrand(id) {
  614. if (this.brandArray.indexOf(id) == -1) {
  615. this.brandArray.push(id)
  616. } else {
  617. this.brandArray.splice(this.brandArray.indexOf(id), 1)
  618. }
  619. },
  620. brandReset() {
  621. this.brandArray = []
  622. this.brandOk();
  623. },
  624. brandOk() {
  625. this.brandtip = false;
  626. this.loadend = false;
  627. this.$set(this.where, 'page', 1);
  628. this.get_product_list(true);
  629. },
  630. // 去详情页
  631. godDetail(item) {
  632. this.currentPage = false
  633. if (this.promotions_type) {
  634. uni.navigateTo({
  635. url: `/pages/goods_details/index?id=${item.id}`
  636. })
  637. } else {
  638. goShopDetail(item, this.uid).then(res => {
  639. uni.navigateTo({
  640. url: `/pages/goods_details/index?id=${item.id}`
  641. })
  642. })
  643. }
  644. },
  645. Changswitch: function() {
  646. let that = this;
  647. this.currentPage = false
  648. that.is_switch = !that.is_switch
  649. },
  650. searchSubmit: function(e) {
  651. let that = this;
  652. this.currentPage = false
  653. that.$set(that.where, 'keyword', e.detail.value);
  654. that.loadend = false;
  655. that.$set(that.where, 'page', 1)
  656. this.get_product_list(true);
  657. },
  658. /**
  659. * 获取我的推荐
  660. */
  661. get_host_product: function() {
  662. let that = this;
  663. if (that.hotScroll) return
  664. getProductHot(
  665. that.hotPage,
  666. that.hotLimit,
  667. ).then(res => {
  668. that.hotPage++
  669. that.hotScroll = res.data.length < that.hotLimit
  670. that.hostProduct = that.hostProduct.concat(res.data)
  671. // that.$set(that, 'hostProduct', res.data)
  672. });
  673. },
  674. //点击事件处理
  675. set_where: function(e) {
  676. this.currentPage = false
  677. switch (e) {
  678. case 1:
  679. // #ifdef H5
  680. return history.back();
  681. // #endif
  682. // #ifndef H5
  683. return uni.navigateBack({
  684. delta: 1,
  685. })
  686. // #endif
  687. break;
  688. case 2:
  689. if (this.price == 0) this.price = 1;
  690. else if (this.price == 1) this.price = 2;
  691. else if (this.price == 2) this.price = 0;
  692. this.stock = 0;
  693. break;
  694. case 3:
  695. if (this.stock == 0) this.stock = 1;
  696. else if (this.stock == 1) this.stock = 2;
  697. else if (this.stock == 2) this.stock = 0;
  698. this.price = 0
  699. break;
  700. case 4:
  701. this.nows = !this.nows;
  702. break;
  703. }
  704. this.loadend = false;
  705. this.$set(this.where, 'page', 1);
  706. this.get_product_list(true);
  707. },
  708. //设置where条件
  709. setWhere: function() {
  710. if (this.price == 0) this.where.priceOrder = '';
  711. else if (this.price == 1) this.where.priceOrder = 'asc';
  712. else if (this.price == 2) this.where.priceOrder = 'desc';
  713. if (this.stock == 0) this.where.salesOrder = '';
  714. else if (this.stock == 1) this.where.salesOrder = 'asc';
  715. else if (this.stock == 2) this.where.salesOrder = 'desc';
  716. this.where.news = this.nows ? 1 : 0;
  717. },
  718. //查找产品
  719. get_product_list: function(isPage) {
  720. let that = this;
  721. that.setWhere();
  722. if (that.loadend) return;
  723. if (that.loading) return;
  724. if (isPage === true) {
  725. if (this.is_switch) {
  726. that.$refs.waterfallsFlow.refresh();
  727. }
  728. that.$set(that, 'productList', []);
  729. }
  730. that.loading = true;
  731. that.loadTitle = '';
  732. that.$set(that.where, 'brand_id', that.brandArray.join(","));
  733. getProductslist(that.where).then(res => {
  734. let list = res.data;
  735. let productList = that.$util.SplitArray(list, that.productList);
  736. let loadend = list.length < that.where.limit;
  737. that.loadend = loadend;
  738. that.loading = false;
  739. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  740. that.$set(that, 'productList', productList);
  741. that.$set(that.where, 'page', that.where.page + 1);
  742. if (!that.productList.length) this.get_host_product();
  743. }).catch(err => {
  744. that.loading = false;
  745. that.loadTitle = '加载更多';
  746. });
  747. },
  748. },
  749. onPullDownRefresh() {
  750. },
  751. onPageScroll(e) {
  752. this.currentPage = false
  753. },
  754. onReachBottom() {
  755. if (this.productList.length > 0) {
  756. this.get_product_list();
  757. } else {
  758. this.get_host_product();
  759. }
  760. }
  761. }
  762. </script>
  763. <style scoped lang="scss">
  764. .height-add {
  765. height: 100rpx;
  766. width: 100%;
  767. }
  768. .home {
  769. color: #333;
  770. width: 56rpx;
  771. height: 56rpx;
  772. background: rgba(255, 255, 255, 1);
  773. border: 1px solid rgba(0, 0, 0, 0.1);
  774. border-radius: 40rpx;
  775. font-size: 33rpx;
  776. &.on {
  777. background: unset;
  778. color: #333;
  779. }
  780. &.homeIndex {
  781. width: 98rpx;
  782. }
  783. }
  784. .home .iconfont {
  785. width: 60rpx;
  786. text-align: center;
  787. font-size: 28rpx;
  788. font-weight: bold;
  789. }
  790. .home .line {
  791. width: 1rpx;
  792. height: 34rpx;
  793. background: #B3B3B3;
  794. }
  795. .home .icon-xiangzuo {
  796. font-size: 28rpx;
  797. }
  798. .clored {
  799. color: var(--view-theme);
  800. font-weight: 600;
  801. .icon-gou {
  802. font-weight: 400 !important;
  803. }
  804. }
  805. .selectbrand {
  806. position: fixed;
  807. background-color: #FFFFFF;
  808. z-index: 8;
  809. width: 100%;
  810. top: 170rpx;
  811. left: 0;
  812. max-height: 860rpx;
  813. overflow: hidden;
  814. overflow-y: auto;
  815. border-radius: 0 0 24rpx 24rpx;
  816. transform: translate3d(0, -100%, 0);
  817. transition: all .2s cubic-bezier(.9, .5, .5, .25);
  818. // padding-top: 200rpx;
  819. // padding-top: calc(200rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  820. // padding-top: calc(200rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  821. .box {
  822. .selet {
  823. display: flex;
  824. flex-wrap: wrap;
  825. padding: 20rpx 20rpx 0 20rpx;
  826. max-height: 520rpx;
  827. overflow-x: hidden;
  828. overflow-y: auto;
  829. .seletbox {
  830. width: 216rpx;
  831. height: 68rpx;
  832. border-radius: 34rpx;
  833. background-color: #F5F5F5;
  834. margin-bottom: 30rpx;
  835. text-align: center;
  836. font-size: 24rpx;
  837. margin-right: 28rpx;
  838. &:nth-child(3n) {
  839. margin-right: 0;
  840. }
  841. }
  842. .seleton {
  843. border: 1px solid var(--view-theme);
  844. background: var(--view-minorColorT);
  845. color: var(--view-theme);
  846. }
  847. }
  848. .btn {
  849. display: flex;
  850. justify-content: space-between;
  851. text-align: center;
  852. padding: 30rpx 20rpx 40rpx;
  853. .sambox {
  854. width: 328rpx;
  855. height: 64rpx;
  856. border-radius: 38rpx;
  857. border: 2rpx solid var(--view-theme);
  858. color: #FFFFFF;
  859. line-height: 64rpx;
  860. }
  861. .reset {
  862. color: var(--view-theme);
  863. }
  864. .ok {
  865. background: var(--view-theme);
  866. }
  867. }
  868. .tlebox {
  869. width: 100%;
  870. height: 88rpx;
  871. line-height: 88rpx;
  872. display: flex;
  873. justify-content: space-between;
  874. padding: 0 40rpx 0 36rpx;
  875. margin-left: 20rpx;
  876. border-bottom: 2rpx solid #EEEEEE;
  877. }
  878. .tlebox:last-child {
  879. border-bottom: 0;
  880. }
  881. }
  882. }
  883. .selectbrand.on {
  884. transform: translate3d(0, 0, 0);
  885. }
  886. .productList .search {
  887. width: 100%;
  888. height: 86rpx;
  889. padding-left: 23rpx;
  890. box-sizing: border-box;
  891. position: fixed;
  892. left: 0;
  893. top: 0;
  894. z-index: 9;
  895. .fanhui {
  896. color: #fff;
  897. }
  898. }
  899. .productList .search .input {
  900. width: 560rpx;
  901. height: 60rpx;
  902. background-color: #fff;
  903. border-radius: 50rpx;
  904. padding: 0 20rpx;
  905. box-sizing: border-box;
  906. &.on {
  907. width: 652rpx;
  908. margin-right: 30rpx;
  909. input {
  910. width: 560rpx;
  911. }
  912. }
  913. }
  914. .productList .search .input input {
  915. width: 466rpx;
  916. height: 100%;
  917. font-size: 26rpx;
  918. }
  919. .productList .search .input .placeholder {
  920. color: #999;
  921. }
  922. .productList .search .input .iconfont {
  923. font-size: 35rpx;
  924. color: #555;
  925. }
  926. .productList .search .icon-pailie,
  927. .productList .search .icon-tupianpailie {
  928. color: #fff;
  929. width: 62rpx;
  930. font-size: 40rpx;
  931. height: 86rpx;
  932. line-height: 86rpx;
  933. }
  934. .productList .nav {
  935. height: 86rpx;
  936. color: #454545;
  937. position: fixed;
  938. left: 0;
  939. width: 100%;
  940. font-size: 28rpx;
  941. background-color: #fff;
  942. margin-top: 86rpx;
  943. top: 0;
  944. z-index: 9;
  945. }
  946. .productList .nav .item {
  947. width: 25%;
  948. text-align: center;
  949. }
  950. .productList .nav .item.font-color {
  951. font-weight: bold;
  952. }
  953. .productList .nav .item image {
  954. width: 15rpx;
  955. height: 19rpx;
  956. margin-left: 10rpx;
  957. }
  958. .productList .list {
  959. padding: 0 20rpx;
  960. margin-top: 172rpx;
  961. }
  962. .productList .list.waterList {
  963. margin-top: 192rpx;
  964. }
  965. .productList .list.on {
  966. background-color: #fff;
  967. border-top: 1px solid #f6f6f6;
  968. .title {
  969. font-size: 22rpx;
  970. color: #333333;
  971. margin-top: 30rpx;
  972. .label {
  973. border-radius: 4rpx;
  974. padding: 2rpx 8rpx;
  975. background-color: var(--view-minorColorT);
  976. font-size: 20rpx;
  977. color: var(--view-theme);
  978. margin-right: 8rpx;
  979. }
  980. }
  981. .footer {
  982. width: 100%;
  983. height: 96rpx;
  984. background-color: #fff;
  985. position: fixed;
  986. bottom: 0;
  987. left: 0;
  988. box-shadow: 0 -4rpx 32rpx 0 rgba(0, 0, 0, 0.08);
  989. padding: 0 20rpx 0 32rpx;
  990. box-sizing: border-box;
  991. bottom: calc(0rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  992. bottom: calc(0rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  993. .right {
  994. color: #888888;
  995. font-size: 20rpx;
  996. margin-left: 32rpx;
  997. .num {
  998. font-size: 28rpx;
  999. color: #333333;
  1000. font-weight: 400;
  1001. .money {
  1002. font-weight: 500;
  1003. }
  1004. }
  1005. }
  1006. .icon {
  1007. width: 72rpx;
  1008. height: 72rpx;
  1009. background: #F5F5F5;
  1010. border-radius: 50%;
  1011. text-align: center;
  1012. line-height: 72rpx;
  1013. position: relative;
  1014. .iconfont {
  1015. font-size: 38rpx;
  1016. }
  1017. .num {
  1018. min-width: 32rpx;
  1019. background-color: #fff;
  1020. color: var(--view-theme);
  1021. border-radius: 15px;
  1022. position: absolute;
  1023. right: -14rpx;
  1024. top: 0;
  1025. font-size: 10px;
  1026. padding: 0 8rpx;
  1027. height: 34rpx;
  1028. line-height: 31rpx;
  1029. border: 1px solid var(--view-theme);
  1030. }
  1031. }
  1032. .bnt {
  1033. width: 192rpx;
  1034. height: 64rpx;
  1035. background: var(--view-theme);
  1036. border-radius: 40rpx;
  1037. color: #FFFFFF;
  1038. font-size: 28rpx;
  1039. text-align: center;
  1040. line-height: 64rpx;
  1041. }
  1042. }
  1043. }
  1044. .productList .list .item {
  1045. width: 345rpx;
  1046. margin-top: 20rpx;
  1047. background-color: #fff;
  1048. border-radius: 20rpx;
  1049. .text {
  1050. &.on {
  1051. .nameCon {
  1052. height: 84rpx;
  1053. }
  1054. .name {
  1055. margin-bottom: 4rpx;
  1056. }
  1057. .label {
  1058. font-size: 20rpx;
  1059. color: var(--view-theme);
  1060. border-radius: 4rpx;
  1061. border: 1px solid var(--view-theme);
  1062. padding: 0 6rpx;
  1063. margin-right: 10rpx;
  1064. }
  1065. .sales {
  1066. color: #999999;
  1067. font-size: 22rpx;
  1068. margin-top: 10rpx;
  1069. .score {
  1070. margin-left: 24rpx;
  1071. }
  1072. .icon {
  1073. width: 48rpx;
  1074. height: 48rpx;
  1075. border-radius: 50%;
  1076. border: 1px solid var(--view-theme);
  1077. font-size: 20rpx;
  1078. color: var(--view-theme);
  1079. }
  1080. }
  1081. }
  1082. }
  1083. }
  1084. .productList .list .item.on {
  1085. width: 100%;
  1086. display: flex;
  1087. border-bottom: 1rpx solid #f6f6f6;
  1088. padding: 30rpx 0;
  1089. margin: 0;
  1090. }
  1091. .productList .list .item .pictrue {
  1092. position: relative;
  1093. width: 100%;
  1094. height: 345rpx;
  1095. }
  1096. .productList .list .item .pictrue.on {
  1097. width: 180rpx;
  1098. height: 180rpx;
  1099. position: relative;
  1100. .masks {
  1101. position: absolute;
  1102. top: 0;
  1103. left: 0;
  1104. right: 0;
  1105. bottom: 0;
  1106. background: rgba(0, 0, 0, 0.2);
  1107. border-radius: 10rpx;
  1108. .bg {
  1109. width: 110rpx;
  1110. height: 110rpx;
  1111. background: #000000;
  1112. opacity: 0.6;
  1113. color: #fff;
  1114. font-size: 22rpx;
  1115. border-radius: 50%;
  1116. padding: 22rpx 0;
  1117. text-align: center;
  1118. }
  1119. }
  1120. }
  1121. .productList .list .item .pictrue image {
  1122. width: 100%;
  1123. height: 100%;
  1124. border-radius: 20rpx 20rpx 0 0;
  1125. }
  1126. .productList .list .item .pictrue image.on {
  1127. border-radius: 6rpx;
  1128. }
  1129. .productList .list .item .text {
  1130. padding: 20rpx 17rpx 26rpx 17rpx;
  1131. font-size: 30rpx;
  1132. color: #222;
  1133. }
  1134. .productList .list .item .text.on {
  1135. width: 508rpx;
  1136. padding: 0 0 0 22rpx;
  1137. }
  1138. .productList .list .item .text .money {
  1139. font-size: 26rpx;
  1140. font-weight: bold;
  1141. margin-top: 8rpx;
  1142. }
  1143. .productList .list .item .text .money.on {
  1144. margin-top: 0;
  1145. margin-right: 5rpx;
  1146. }
  1147. .productList .list .item .text .money .num {
  1148. font-size: 34rpx;
  1149. }
  1150. .productList .list .item .text .vip {
  1151. font-size: 22rpx;
  1152. color: #aaa;
  1153. margin-top: 7rpx;
  1154. }
  1155. .productList .list .item .text .vip.on {
  1156. margin-top: 12rpx;
  1157. }
  1158. .productList .list .item .text .vip .vip-money {
  1159. font-size: 24rpx;
  1160. color: #282828;
  1161. font-weight: 600;
  1162. }
  1163. .productList .list .vip .vip-money .icon {
  1164. font-size: 15rpx;
  1165. background: #FF9500;
  1166. color: #fff;
  1167. border-radius: 18rpx;
  1168. padding: 1rpx 6rpx;
  1169. margin-left: 10rpx;
  1170. min-width: 60rpx;
  1171. .iconfont {
  1172. font-size: 15rpx;
  1173. margin-right: 5rpx;
  1174. }
  1175. &.on {
  1176. background: #333;
  1177. color: #FDDAA4;
  1178. min-width: unset;
  1179. }
  1180. }
  1181. .productList .list .item .text .vip .vip-money image {
  1182. width: 46rpx;
  1183. height: 21rpx;
  1184. margin-left: 4rpx;
  1185. }
  1186. .noCommodity {
  1187. background-color: #fff;
  1188. padding-bottom: 30rpx;
  1189. .emptyBox{
  1190. text-align: center;
  1191. .tips{
  1192. color: #aaa;
  1193. font-size: 26rpx;
  1194. }
  1195. image {
  1196. width: 414rpx;
  1197. height: 304rpx;
  1198. }
  1199. }
  1200. }
  1201. .waterfalls {
  1202. padding: 10rpx 16rpx 16rpx 16rpx;
  1203. color: #222;
  1204. .name {
  1205. font-size: 28rpx;
  1206. }
  1207. .label {
  1208. font-size: 20rpx;
  1209. color: var(--view-theme);
  1210. border-radius: 4rpx;
  1211. border: 1px solid var(--view-theme);
  1212. padding: 0 6rpx;
  1213. display: inline-block;
  1214. margin-top: 10rpx;
  1215. margin-right: 10rpx;
  1216. }
  1217. .money {
  1218. font-size: 26rpx;
  1219. font-weight: 700;
  1220. .num {
  1221. font-size: 34rpx;
  1222. }
  1223. .nums {
  1224. font-size: 28rpx;
  1225. }
  1226. }
  1227. .vip {
  1228. font-size: 22rpx;
  1229. color: #aaa;
  1230. margin-top: 6rpx;
  1231. .vip-money {
  1232. font-size: 24rpx;
  1233. color: #282828;
  1234. font-weight: bold;
  1235. image {
  1236. width: 46rpx;
  1237. height: 21rpx;
  1238. margin-left: 4rpx;
  1239. }
  1240. }
  1241. }
  1242. }
  1243. </style>