index.vue 35 KB

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