order_addcart.vue 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790
  1. <template>
  2. <view :style="colorStyle">
  3. <view class='shoppingCart copy-data' v-if="canShow">
  4. <view class='labelNav acea-row row-around row-middle'>
  5. <view class='item'><text class='iconfont icon-xuanzhong'></text>{{ $t(`100%正品保证`) }}</view>
  6. <view class='item'><text class='iconfont icon-xuanzhong'></text>{{ $t(`所有商品精挑细选`) }}</view>
  7. <view class='item'><text class='iconfont icon-xuanzhong'></text>{{ $t(`售后无忧`) }}</view>
  8. </view>
  9. <view class='nav acea-row row-between-wrapper'>
  10. <view>{{ $t(`购物数量`) }} <text class='num font-num'>{{ cartCount }}</text></view>
  11. <view v-if="cartList.valid.length > 0 || cartList.invalid.length > 0"
  12. class='administrate acea-row row-center-wrapper' @click='manage'>{{ footerswitch ? $t(`管理`) :
  13. $t(`取消`)
  14. }}
  15. </view>
  16. </view>
  17. <view v-if="(cartList.valid.length > 0 || cartList.invalid.length > 0) && canShow">
  18. <view class='list'>
  19. <checkbox-group @change="checkboxChange">
  20. <block v-for="(item, index) in cartList.valid" :key="index">
  21. <view class='item acea-row row-between-wrapper'>
  22. <!-- #ifndef MP -->
  23. <checkbox :value="(item.id).toString()" :checked="item.checked"
  24. :disabled="!item.attrStatus && footerswitch" />
  25. <!-- <checkbox :value="(item.id).toString()" :checked="item.checked" :disabled="item.attrStatus?false:true" /> -->
  26. <!-- #endif -->
  27. <!-- #ifdef MP -->
  28. <checkbox :value="item.id" :checked="item.checked"
  29. :disabled="!item.attrStatus && footerswitch" />
  30. <!-- #endif -->
  31. <navigator :url='"/pages/goods_details/index?id=" + item.product_id' hover-class='none'
  32. class='picTxt acea-row row-between-wrapper'>
  33. <view class='pictrue'>
  34. <image v-if="item.productInfo.attrInfo" :src='item.productInfo.attrInfo.image'>
  35. </image>
  36. <image v-else :src='item.productInfo.image'></image>
  37. </view>
  38. <view class='text'>
  39. <view class='line1' :class="item.attrStatus ? '' : 'reColor'">
  40. {{ item.productInfo.store_name }}
  41. </view>
  42. <view class='infor line1' v-if="item.productInfo.attrInfo">
  43. {{ $t(`属性`) }}:{{ item.productInfo.attrInfo.suk }}</view>
  44. <view class='money' v-if="item.attrStatus">{{ $t(`¥`) }}{{ item.truePrice }}
  45. </view>
  46. <view class="reElection acea-row row-between-wrapper" v-else>
  47. <view class="title">{{ $t(`请重新选择商品规格`) }}</view>
  48. <view class="reBnt cart-color acea-row row-center-wrapper"
  49. @click.stop="reElection(item)">{{ $t(`重选`) }}</view>
  50. </view>
  51. </view>
  52. <view class='carnum acea-row row-center-wrapper' v-if="item.attrStatus">
  53. <view class="reduce" :class="item.numSub ? 'on' : ''"
  54. @click.stop='subCart(index)'>-</view>
  55. <!-- <view class='num'>{{item.cart_num}}</view> -->
  56. <view class="num">
  57. <input type="number" v-model="item.cart_num" @click.stop
  58. @input="iptCartNum(index)" @blur="blurInput(index)" />
  59. </view>
  60. <view class="plus" :class="item.numAdd ? 'on' : ''"
  61. @click.stop='addCart(index)'>+</view>
  62. </view>
  63. </navigator>
  64. </view>
  65. </block>
  66. </checkbox-group>
  67. </view>
  68. <view class='invalidGoods' v-if="cartList.invalid.length > 0">
  69. <view class='goodsNav acea-row row-between-wrapper'>
  70. <view @click='goodsOpen'><text class='iconfont'
  71. :class='goodsHidden == true ? "icon-xiangxia" : "icon-xiangshang"'></text>{{ $t(`失效商品`)
  72. }}
  73. </view>
  74. <view class='del' @click='unsetCart'><text class='iconfont icon-shanchu1'></text>{{ $t(`清空`) }}
  75. </view>
  76. </view>
  77. <view class='goodsList' :hidden='goodsHidden'>
  78. <block v-for="(item, index) in cartList.invalid" :key='index'>
  79. <view class='item acea-row row-between-wrapper'>
  80. <view class='invalid'>{{ $t(`失效`) }}</view>
  81. <view class='pictrue'>
  82. <image v-if="item.productInfo.attrInfo" :src='item.productInfo.attrInfo.image'>
  83. </image>
  84. <image v-else :src='item.productInfo.image'></image>
  85. </view>
  86. <view class='text acea-row row-column-between'>
  87. <view class='line1 name'>{{ item.productInfo.store_name }}</view>
  88. <view class='infor line1' v-if="item.productInfo.attrInfo">
  89. {{ $t(`属性`) }}:{{ item.productInfo.attrInfo.suk }}</view>
  90. <view class='acea-row row-between-wrapper'>
  91. <!-- <view>¥{{item.truePrice}}</view> -->
  92. <view class='end'>{{ $t(`该商品已失效`) }}</view>
  93. </view>
  94. </view>
  95. </view>
  96. </block>
  97. </view>
  98. </view>
  99. <!-- <view class='loadingicon acea-row row-center-wrapper' v-if="cartList.valid.length&&!loadend">
  100. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  101. </view> -->
  102. <view class='loadingicon acea-row row-center-wrapper' v-if="cartList.invalid.length && loadend">
  103. <text class='loading iconfont icon-jiazai' :hidden='loadingInvalid == false'></text>{{
  104. loadTitleInvalid
  105. }}
  106. </view>
  107. </view>
  108. <view class='noCart' v-if="cartList.valid.length == 0 && cartList.invalid.length == 0 && canShow">
  109. <view class='emptyBox'>
  110. <image :src="imgHost + '/statics/images/no-thing.png'"></image>
  111. <view class="tips">{{ $t(`全选`) }}</view>
  112. </view>
  113. <recommend :hostProduct='hostProduct'></recommend>
  114. </view>
  115. <view style='height:120rpx;color: #F5F5F5;'></view>
  116. <view class='footer acea-row row-between-wrapper' v-if="cartList.valid.length > 0 && canShow"
  117. :class="is_diy && is_diy_set ? 'on' : ''">
  118. <view>
  119. <checkbox-group @change="checkboxAllChange">
  120. <checkbox value="all" :checked="!!isAllSelect" />
  121. <text class='checkAll'>{{ $t(`全选`) }}({{ selectValue.length }})</text>
  122. </checkbox-group>
  123. </view>
  124. <view class='money acea-row row-middle' v-if="footerswitch == true">
  125. <text class='font-color'>{{ $t(`¥`) }}{{ selectCountPrice }}</text>
  126. <form @submit="subOrder">
  127. <button class='placeOrder bg-color' formType="submit">{{ $t(`立即下单`) }}</button>
  128. </form>
  129. </view>
  130. <view class='button acea-row row-middle' v-else>
  131. <form @submit="subCollect">
  132. <button class='bnt cart-color' formType="submit">{{ $t(`收藏`) }}</button>
  133. </form>
  134. <form @submit="subDel">
  135. <button class='bnt' formType="submit">{{ $t(`删除`) }}</button>
  136. </form>
  137. </view>
  138. </view>
  139. </view>
  140. <productWindow :attr="attr" :isShow='1' :iSplus='1' :iScart='1' @myevent="onMyEvent" @ChangeAttr="ChangeAttr"
  141. @ChangeCartNum="ChangeCartNum" @attrVal="attrVal" @iptCartNum="iptCartNum" @goCat="reGoCat"
  142. id='product-window'></productWindow>
  143. <!-- #ifdef MP -->
  144. <!-- <authorize :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  145. <!-- #endif -->
  146. <!-- <view class="uni-p-b-96"></view> -->
  147. <view class="uni-p-b-98"></view>
  148. <!-- <pageFooter :countNum="cartCount"></pageFooter> -->
  149. <view class="foot" v-if="is_diy && newData.status && newData.status.status">
  150. <view class="page-footer" id="target" :style="{ 'background-color': newData.bgColor.color[0].item }">
  151. <view class="foot-item" v-for="(item, index) in newData.menuList" :key="index" @click="goRouter(item)">
  152. <block v-if="item.link == activeRouter">
  153. <image :src="item.imgList[0]"></image>
  154. <view class="txt" :style="{ color: newData.activeTxtColor.color[0].item }">{{ item.name }}
  155. </view>
  156. </block>
  157. <block v-else>
  158. <image :src="item.imgList[1]"></image>
  159. <view class="txt" :style="{ color: newData.txtColor.color[0].item }">{{ item.name }}</view>
  160. </block>
  161. <div class="count-num" v-if="item.link === '/pages/order_addcart/order_addcart' && cartCount > 0">
  162. {{ cartCount }}
  163. </div>
  164. </view>
  165. </view>
  166. </view>
  167. </view>
  168. </template>
  169. <script>
  170. // #ifdef APP-PLUS
  171. let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  172. // #endif
  173. // #ifndef APP-PLUS
  174. let sysHeight = 0
  175. // #endif
  176. import {
  177. getCartList,
  178. getCartCounts,
  179. changeCartNum,
  180. cartDel,
  181. getResetCart
  182. } from '@/api/order.js';
  183. import {
  184. getProductHot,
  185. collectAll,
  186. getProductDetail
  187. } from '@/api/store.js';
  188. import {
  189. toLogin
  190. } from '@/libs/login.js';
  191. import {
  192. mapGetters
  193. } from "vuex";
  194. import recommend from '@/components/recommend';
  195. import productWindow from '@/components/productWindow';
  196. // #ifdef MP
  197. import authorize from '@/components/Authorize';
  198. // #endif
  199. import pageFooter from '@/components/pageFooter/index.vue'
  200. import colors from "@/mixins/color";
  201. import { HTTP_REQUEST_URL } from '@/config/app';
  202. const hot_res = require('@/mock/json/hot_res.json')
  203. import {
  204. getNavigation
  205. } from '@/api/public.js'
  206. export default {
  207. components: {
  208. pageFooter,
  209. recommend,
  210. productWindow,
  211. // #ifdef MP
  212. authorize
  213. // #endif
  214. },
  215. mixins: [colors],
  216. data() {
  217. return {
  218. imgHost: HTTP_REQUEST_URL,
  219. is_diy: uni.getStorageSync('is_diy'),
  220. canShow: false,
  221. cartCount: 0,
  222. goodsHidden: true,
  223. footerswitch: true,
  224. hostProduct: [],
  225. cartList: {
  226. valid: [],
  227. invalid: []
  228. },
  229. isAllSelect: false, //全选
  230. selectValue: [], //选中的数据
  231. selectCountPrice: 0.00,
  232. isAuto: false, //没有授权的不会自动授权
  233. isShowAuth: false, //是否隐藏授权
  234. hotScroll: false,
  235. hotPage: 1,
  236. hotLimit: 10,
  237. loading: false,
  238. loadend: false,
  239. loadTitle: this.$t(`我也是有底线的`), //提示语
  240. page: 1,
  241. limit: 20,
  242. loadingInvalid: false,
  243. loadendInvalid: false,
  244. loadTitleInvalid: this.$t(`加载更多`), //提示语
  245. pageInvalid: 1,
  246. limitInvalid: 20,
  247. attr: {
  248. cartAttr: false,
  249. productAttr: [],
  250. productSelect: {}
  251. },
  252. productValue: [], //系统属性
  253. storeInfo: {},
  254. attrValue: '', //已选属性
  255. attrTxt: this.$t(`请选择`), //属性页面提示
  256. cartId: 0,
  257. product_id: 0,
  258. sysHeight: sysHeight,
  259. newData: {},
  260. activeRouter: '',
  261. is_diy_set: false
  262. };
  263. },
  264. computed: mapGetters(['isLogin']),
  265. onLoad(options) {
  266. // if (this.is_diy) {
  267. // if (uni.getStorageSync('FOOTER_BAR')) {
  268. // uni.hideTabBar()
  269. // } else {
  270. // this.is_diy_set = true
  271. // }
  272. // uni.request({
  273. // url:'api/mock/navigation',
  274. // success:res=>{
  275. // this.newData = res.data
  276. // if (this.newData.status && this.newData.status.status) {
  277. // uni.hideTabBar()
  278. // } else {
  279. // uni.showTabBar()
  280. // }
  281. // }
  282. // })
  283. // // getNavigation().then(res => {
  284. // // this.newData = res.data
  285. // // if (this.newData.status && this.newData.status.status) {
  286. // // uni.hideTabBar()
  287. // // } else {
  288. // // uni.showTabBar()
  289. // // }
  290. // // })
  291. // } else {
  292. // uni.hideTabBar()
  293. // }
  294. let that = this;
  295. if (that.isLogin == false) {
  296. toLogin();
  297. }
  298. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  299. let curRoute = routes[routes.length - 1].route //获取当前页面路由
  300. this.activeRouter = '/' + curRoute
  301. },
  302. onShow() {
  303. this.canShow = false
  304. if (this.isLogin == true) {
  305. this.hotPage = 1;
  306. this.hostProduct = [],
  307. this.hotScroll = false,
  308. this.getHostProduct();
  309. this.loadend = false;
  310. this.page = 1;
  311. this.cartList.valid = [];
  312. this.getCartList();
  313. this.loadendInvalid = false;
  314. this.pageInvalid = 1;
  315. this.cartList.invalid = [];
  316. this.getInvalidList();
  317. this.getCartNum();
  318. this.goodsHidden = true;
  319. this.footerswitch = true;
  320. this.hostProduct = [];
  321. this.hotScroll = false;
  322. this.hotPage = 1;
  323. this.hotLimit = 10;
  324. this.cartList = {
  325. valid: [],
  326. invalid: []
  327. },
  328. this.isAllSelect = false; //全选
  329. this.selectValue = []; //选中的数据
  330. this.selectCountPrice = 0.00;
  331. this.cartCount = 0;
  332. this.isShowAuth = false;
  333. };
  334. },
  335. methods: {
  336. // 授权关闭
  337. authColse: function (e) {
  338. this.isShowAuth = e;
  339. },
  340. // 修改购物车
  341. reGoCat: function () {
  342. let that = this,
  343. productSelect = that.productValue[this.attrValue];
  344. //如果有属性,没有选择,提示用户选择
  345. if (
  346. that.attr.productAttr.length &&
  347. productSelect === undefined
  348. )
  349. return that.$util.Tips({
  350. title: that.$t(`产品库存不足,请选择其它`)
  351. });
  352. let q = {
  353. id: that.cartId,
  354. product_id: that.product_id,
  355. num: that.attr.productSelect.cart_num,
  356. unique: that.attr.productSelect !== undefined ?
  357. that.attr.productSelect.unique : ""
  358. };
  359. getResetCart(q)
  360. .then(function (res) {
  361. that.attr.cartAttr = false;
  362. that.$util.Tips({
  363. title: that.$t(`添加购物车成功`),
  364. success: () => {
  365. that.loadend = false;
  366. that.page = 1;
  367. that.cartList.valid = [];
  368. that.getCartList();
  369. that.getCartNum();
  370. }
  371. });
  372. })
  373. .catch(res => {
  374. return that.$util.Tips({
  375. title: res.msg
  376. });
  377. });
  378. },
  379. onMyEvent: function () {
  380. this.$set(this.attr, 'cartAttr', false);
  381. },
  382. reElection: function (item) {
  383. this.getGoodsDetails(item)
  384. },
  385. /**
  386. * 获取产品详情
  387. *
  388. */
  389. getGoodsDetails: function (item) {
  390. uni.showLoading({
  391. title: this.$t(`加载中`),
  392. mask: true
  393. });
  394. let that = this;
  395. that.cartId = item.id;
  396. that.product_id = item.product_id;
  397. getProductDetail(item.product_id).then(res => {
  398. uni.hideLoading();
  399. that.attr.cartAttr = true;
  400. let storeInfo = res.data.storeInfo;
  401. that.$set(that, 'storeInfo', storeInfo);
  402. that.$set(that.attr, 'productAttr', res.data.productAttr);
  403. that.$set(that, 'productValue', res.data.productValue);
  404. that.DefaultSelect();
  405. }).catch(err => {
  406. uni.hideLoading();
  407. })
  408. },
  409. /**
  410. * 属性变动赋值
  411. *
  412. */
  413. ChangeAttr: function (res) {
  414. let productSelect = this.productValue[res];
  415. if (productSelect && productSelect.stock > 0) {
  416. this.$set(this.attr.productSelect, "image", productSelect.image);
  417. this.$set(this.attr.productSelect, "price", productSelect.price);
  418. this.$set(this.attr.productSelect, "stock", productSelect.stock);
  419. this.$set(this.attr.productSelect, "unique", productSelect.unique);
  420. this.$set(this.attr.productSelect, "cart_num", 1);
  421. this.$set(this, "attrValue", res);
  422. this.$set(this, "attrTxt", this.$t(`已选择`));
  423. } else {
  424. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  425. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  426. this.$set(this.attr.productSelect, "stock", 0);
  427. this.$set(this.attr.productSelect, "unique", "");
  428. this.$set(this.attr.productSelect, "cart_num", 0);
  429. this.$set(this, "attrValue", "");
  430. this.$set(this, "attrTxt", this.$t(`请选择`));
  431. }
  432. },
  433. /**
  434. * 默认选中属性
  435. *
  436. */
  437. DefaultSelect: function () {
  438. let productAttr = this.attr.productAttr;
  439. let value = [];
  440. for (var key in this.productValue) {
  441. if (this.productValue[key].stock > 0) {
  442. value = this.attr.productAttr.length ? key.split(",") : [];
  443. break;
  444. }
  445. }
  446. for (let i = 0; i < productAttr.length; i++) {
  447. this.$set(productAttr[i], "index", value[i]);
  448. }
  449. //sort();排序函数:数字-英文-汉字;
  450. let productSelect = this.productValue[value.sort().join(",")];
  451. if (productSelect && productAttr.length) {
  452. this.$set(
  453. this.attr.productSelect,
  454. "store_name",
  455. this.storeInfo.store_name
  456. );
  457. this.$set(this.attr.productSelect, "image", productSelect.image);
  458. this.$set(this.attr.productSelect, "price", productSelect.price);
  459. this.$set(this.attr.productSelect, "stock", productSelect.stock);
  460. this.$set(this.attr.productSelect, "unique", productSelect.unique);
  461. this.$set(this.attr.productSelect, "cart_num", 1);
  462. this.$set(this, "attrValue", value.sort().join(","));
  463. this.$set(this, "attrTxt", this.$t(`已选择`));
  464. } else if (!productSelect && productAttr.length) {
  465. this.$set(
  466. this.attr.productSelect,
  467. "store_name",
  468. this.storeInfo.store_name
  469. );
  470. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  471. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  472. this.$set(this.attr.productSelect, "stock", 0);
  473. this.$set(this.attr.productSelect, "unique", "");
  474. this.$set(this.attr.productSelect, "cart_num", 0);
  475. this.$set(this, "attrValue", "");
  476. this.$set(this, "attrTxt", this.$t(`请选择`));
  477. } else if (!productSelect && !productAttr.length) {
  478. this.$set(
  479. this.attr.productSelect,
  480. "store_name",
  481. this.storeInfo.store_name
  482. );
  483. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  484. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  485. this.$set(this.attr.productSelect, "stock", this.storeInfo.stock);
  486. this.$set(
  487. this.attr.productSelect,
  488. "unique",
  489. this.storeInfo.unique || ""
  490. );
  491. this.$set(this.attr.productSelect, "cart_num", 1);
  492. this.$set(this, "attrValue", "");
  493. this.$set(this, "attrTxt", this.$t(`请选择`));
  494. }
  495. },
  496. attrVal(val) {
  497. this.$set(this.attr.productAttr[val.indexw], 'index', this.attr.productAttr[val.indexw].attr_values[val
  498. .indexn]);
  499. },
  500. /**
  501. * 购物车数量加和数量减
  502. *
  503. */
  504. ChangeCartNum: function (changeValue) {
  505. //changeValue:是否 加|减
  506. //获取当前变动属性
  507. let productSelect = this.productValue[this.attrValue];
  508. //如果没有属性,赋值给商品默认库存
  509. if (productSelect === undefined && !this.attr.productAttr.length)
  510. productSelect = this.attr.productSelect;
  511. //无属性值即库存为0;不存在加减;
  512. if (productSelect === undefined) return;
  513. let stock = productSelect.stock || 0;
  514. let num = this.attr.productSelect;
  515. if (changeValue) {
  516. num.cart_num++;
  517. if (num.cart_num > stock) {
  518. this.$set(this.attr.productSelect, "cart_num", stock ? stock : 1);
  519. this.$set(this, "cart_num", stock ? stock : 1);
  520. }
  521. } else {
  522. num.cart_num--;
  523. if (num.cart_num < 1) {
  524. this.$set(this.attr.productSelect, "cart_num", 1);
  525. this.$set(this, "cart_num", 1);
  526. }
  527. }
  528. },
  529. /**
  530. * 购物车手动填写
  531. *
  532. */
  533. iptCartNum: function (e) {
  534. this.$set(this.attr.productSelect, 'cart_num', e);
  535. },
  536. subDel: function (event) {
  537. let that = this,
  538. selectValue = that.selectValue;
  539. if (selectValue.length > 0)
  540. cartDel(selectValue).then(res => {
  541. that.loadend = false;
  542. that.page = 1;
  543. that.cartList.valid = [];
  544. that.getCartList();
  545. that.getCartNum();
  546. });
  547. else
  548. return that.$util.Tips({
  549. title: that.$t(`请选择产品`)
  550. });
  551. },
  552. getSelectValueProductId: function () {
  553. let that = this;
  554. let validList = that.cartList.valid;
  555. let selectValue = that.selectValue;
  556. let productId = [];
  557. if (selectValue.length > 0) {
  558. for (let index in validList) {
  559. if (that.inArray(validList[index].id, selectValue)) {
  560. productId.push(validList[index].product_id);
  561. }
  562. }
  563. };
  564. return productId;
  565. },
  566. subCollect: function (event) {
  567. let that = this,
  568. selectValue = that.selectValue;
  569. if (selectValue.length > 0) {
  570. let selectValueProductId = that.getSelectValueProductId();
  571. collectAll(that.getSelectValueProductId().join(',')).then(res => {
  572. return that.$util.Tips({
  573. title: res.msg,
  574. icon: 'success'
  575. });
  576. }).catch(err => {
  577. return that.$util.Tips({
  578. title: err
  579. });
  580. });
  581. } else {
  582. return that.$util.Tips({
  583. title: that.$t(`请选择产品`)
  584. });
  585. }
  586. },
  587. subOrder(event) {
  588. console.log(event)
  589. let that = this,
  590. selectValue = that.selectValue;
  591. if (selectValue.length > 0) {
  592. uni.navigateTo({
  593. url: '/pages/goods/order_confirm/index?cartId=' + selectValue.join(',')
  594. });
  595. } else {
  596. return that.$util.Tips({
  597. title: that.$t(`请选择产品`)
  598. });
  599. }
  600. },
  601. checkboxAllChange: function (event) {
  602. let value = event.detail.value;
  603. if (value.length > 0) {
  604. this.setAllSelectValue(1)
  605. } else {
  606. this.setAllSelectValue(0)
  607. }
  608. },
  609. setAllSelectValue: function (status) {
  610. let that = this;
  611. let selectValue = [];
  612. let valid = that.cartList.valid;
  613. if (valid.length > 0) {
  614. let newValid = valid.map(item => {
  615. if (status) {
  616. if (that.footerswitch) {
  617. if (item.attrStatus) {
  618. item.checked = true;
  619. selectValue.push(item.id);
  620. } else {
  621. item.checked = false;
  622. }
  623. } else {
  624. item.checked = true;
  625. selectValue.push(item.id);
  626. }
  627. that.isAllSelect = true;
  628. } else {
  629. item.checked = false;
  630. that.isAllSelect = false;
  631. }
  632. return item;
  633. });
  634. that.$set(that.cartList, 'valid', newValid);
  635. that.selectValue = selectValue;
  636. that.switchSelect();
  637. }
  638. },
  639. checkboxChange: function (event) {
  640. let that = this;
  641. let value = event.detail.value;
  642. let valid = that.cartList.valid;
  643. let arr1 = [];
  644. let arr2 = [];
  645. let arr3 = [];
  646. let newValid = valid.map(item => {
  647. if (that.inArray(item.id, value)) {
  648. if (that.footerswitch) {
  649. if (item.attrStatus) {
  650. item.checked = true;
  651. arr1.push(item);
  652. } else {
  653. item.checked = false;
  654. }
  655. } else {
  656. item.checked = true;
  657. arr1.push(item);
  658. }
  659. } else {
  660. item.checked = false;
  661. arr2.push(item);
  662. }
  663. return item;
  664. });
  665. if (that.footerswitch) {
  666. arr3 = arr2.filter(item => !item.attrStatus);
  667. }
  668. // for (let index in valid) {
  669. // if (that.inArray(valid[index].id, value)){
  670. // if(valid[index].attrStatus){
  671. // valid[index].checked = true;
  672. // }else{
  673. // valid[index].checked = false;
  674. // }
  675. // } else {
  676. // valid[index].checked = false;
  677. // }
  678. // }
  679. that.$set(that.cartList, 'valid', newValid);
  680. // let newArr = that.cartList.valid.filter(item => item.attrStatus);
  681. that.isAllSelect = newValid.length === arr1.length + arr3.length;
  682. that.selectValue = value;
  683. that.switchSelect();
  684. },
  685. inArray: function (search, array) {
  686. for (let i in array) {
  687. if (array[i] == search) {
  688. return true;
  689. }
  690. }
  691. return false;
  692. },
  693. switchSelect: function () {
  694. let that = this;
  695. let validList = that.cartList.valid;
  696. let selectValue = that.selectValue;
  697. let selectCountPrice = 0.00;
  698. if (selectValue.length < 1) {
  699. that.selectCountPrice = selectCountPrice;
  700. } else {
  701. for (let index in validList) {
  702. if (that.inArray(validList[index].id, selectValue)) {
  703. selectCountPrice = that.$util.$h.Add(selectCountPrice, that.$util.$h.Mul(validList[index]
  704. .cart_num, validList[
  705. index].truePrice))
  706. }
  707. }
  708. that.selectCountPrice = selectCountPrice;
  709. }
  710. },
  711. /**
  712. * 购物车手动填写
  713. *
  714. */
  715. iptCartNum: function (index) {
  716. let item = this.cartList.valid[index];
  717. if (item.cart_num) {
  718. this.setCartNum(item.id, item.cart_num);
  719. }
  720. this.switchSelect();
  721. },
  722. blurInput: function (index) {
  723. let item = this.cartList.valid[index];
  724. console.log(item)
  725. if (!item.cart_num) {
  726. item.cart_num = 1;
  727. this.$set(this.cartList, 'valid', this.cartList.valid)
  728. }
  729. },
  730. subCart: function (index) {
  731. let that = this;
  732. let status = false;
  733. let item = that.cartList.valid[index];
  734. item.cart_num = Number(item.cart_num) - 1;
  735. if (item.cart_num < 1) status = true;
  736. if (item.cart_num <= 1) {
  737. item.cart_num = 1;
  738. item.numSub = true;
  739. } else {
  740. item.numSub = false;
  741. item.numAdd = false;
  742. }
  743. if (false == status) {
  744. that.setCartNum(item.id, item.cart_num, function (data) {
  745. that.cartList.valid[index] = item;
  746. that.getCartNum();
  747. that.switchSelect();
  748. });
  749. }
  750. },
  751. addCart: function (index) {
  752. let that = this;
  753. let item = that.cartList.valid[index];
  754. item.cart_num = Number(item.cart_num) + 1;
  755. let productInfo = item.productInfo;
  756. if (productInfo.hasOwnProperty('attrInfo') && item.cart_num >= item.productInfo.attrInfo.stock) {
  757. item.cart_num = item.productInfo.attrInfo.stock;
  758. item.numAdd = true;
  759. item.numSub = false;
  760. } else {
  761. item.numAdd = false;
  762. item.numSub = false;
  763. }
  764. that.setCartNum(item.id, item.cart_num, function (data) {
  765. that.cartList.valid[index] = item;
  766. that.getCartNum();
  767. that.switchSelect();
  768. });
  769. },
  770. setCartNum(cartId, cartNum, successCallback) {
  771. let that = this;
  772. changeCartNum(cartId, cartNum).then(res => {
  773. console.log(res)
  774. successCallback && successCallback(res.data);
  775. }).catch(err => {
  776. console.log(err)
  777. return that.$util.Tips({
  778. title: err
  779. });
  780. })
  781. },
  782. getCartNum: function () {
  783. let that = this;
  784. // getCartCounts().then(res => {
  785. that.cartCount = 0;
  786. this.$store.commit('indexData/setCartNum', that.cartCount > 99 ? '..' : that.cartCount)
  787. if (that.cartCount > 0) {
  788. wx.setTabBarBadge({
  789. index: 2,
  790. text: that.cartCount + ''
  791. })
  792. } else {
  793. wx.hideTabBarRedDot({
  794. index: 2
  795. })
  796. }
  797. // });
  798. },
  799. getCartData(data) {
  800. let resData = {
  801. "valid": [],
  802. "invalid": [],
  803. "deduction": {
  804. "seckill_id": 0,
  805. "bargain_id": 0,
  806. "combination_id": 0,
  807. "discount_id": 0
  808. }
  809. }
  810. this.loading = false;
  811. this.canShow = true
  812. return resData;
  813. // return new Promise((resolve, reject) => {
  814. // getCartList(data).then((res) => {
  815. // resolve(res.data);
  816. // }).catch((err) => {
  817. // this.loading = false;
  818. // this.canShow = true
  819. // this.$util.Tips({
  820. // title: err
  821. // });
  822. // })
  823. // });
  824. },
  825. async getCartList() {
  826. uni.showLoading({
  827. title: this.$t(`加载中`),
  828. mask: true
  829. });
  830. let that = this;
  831. let data = {
  832. page: that.page,
  833. limit: that.limit,
  834. status: 1
  835. }
  836. let countResData = {
  837. "count": 0,
  838. "ids": [
  839. 9671,
  840. 9670,
  841. 9669
  842. ],
  843. "sum_price": "955.00"
  844. }
  845. // getCartCounts().then(async c => {
  846. that.cartCount = countResData.count;
  847. let n = Math.ceil(countResData.ids.length / that.limit)
  848. for (let i = 0; i < n; i++) {
  849. // let cartList = await this.getCartData(data)
  850. let cartListData = {
  851. "valid": [
  852. {
  853. "id": 9671,
  854. "uid": 34391,
  855. "type": "0",
  856. "product_id": 97,
  857. "product_attr_unique": "fd6d98f3",
  858. "cart_num": 1,
  859. "add_time": 1666709939,
  860. "is_pay": 0,
  861. "is_del": 0,
  862. "is_new": 0,
  863. "combination_id": 0,
  864. "seckill_id": 0,
  865. "bargain_id": 0,
  866. "advance_id": 0,
  867. "status": 1,
  868. "productInfo": {
  869. "id": 97,
  870. "mer_id": 0,
  871. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/small_0d407b8541efd8c8f87e5ac581d1421c.png",
  872. "recommend_image": "",
  873. "slider_image": [
  874. "https://demo26.crmeb.net/uploads/attach/2021/11/13/2d97c9bd7abcdb65049c97bbe9ba61d1.jpg",
  875. "https://demo26.crmeb.net/uploads/attach/2021/11/13/a48cce02122f4046193bdda67d970b55.jpg",
  876. "https://demo26.crmeb.net/uploads/attach/2021/11/13/5c4754f2b647b9e240e08f48c9889ebf.jpg",
  877. "https://demo26.crmeb.net/uploads/attach/2021/11/13/e8f6b1235f10f83d8a43bd91def20332.jpg",
  878. "https://demo26.crmeb.net/uploads/attach/2021/11/13/634a51ad34590eab005063742d086b87.jpg"
  879. ],
  880. "store_name": "仟佰家 干花花束真花手工落地高枝装饰摆件招财莲蓬插花居客厅摆设 干花组合6025【不含花瓶】 干花包",
  881. "store_info": "仟佰家 干花花束真花手工落地高枝装饰摆件招财莲蓬插花居客厅摆设 干花组合6025【不含花瓶】 干花包",
  882. "keyword": "",
  883. "bar_code": "",
  884. "cate_id": "22,24",
  885. "price": "306.00",
  886. "vip_price": "0.00",
  887. "ot_price": "299.00",
  888. "postage": "0.00",
  889. "unit_name": "件",
  890. "sort": 100,
  891. "sales": 2,
  892. "stock": 12384,
  893. "is_show": 1,
  894. "is_hot": 0,
  895. "is_benefit": 0,
  896. "is_best": 0,
  897. "is_new": 1,
  898. "is_virtual": 0,
  899. "virtual_type": 0,
  900. "add_time": 1636791973,
  901. "is_postage": 0,
  902. "is_del": 0,
  903. "mer_use": 0,
  904. "give_integral": "0.00",
  905. "cost": "258.00",
  906. "is_seckill": 0,
  907. "is_bargain": null,
  908. "is_good": 0,
  909. "is_sub": 0,
  910. "is_vip": 0,
  911. "ficti": 0,
  912. "browse": 0,
  913. "code_path": "",
  914. "soure_link": "",
  915. "temp_id": 57,
  916. "spec_type": 1,
  917. "activity": "0,1,2,3",
  918. "spu": "5310153503736",
  919. "label_id": "0",
  920. "video_link": "",
  921. "command_word": "",
  922. "recommend_list": "",
  923. "vip_product": 0,
  924. "presale": 0,
  925. "presale_start_time": 0,
  926. "presale_end_time": 0,
  927. "presale_day": 0,
  928. "logistics": "1,2",
  929. "freight": 2,
  930. "custom_form": "",
  931. "is_limit": 0,
  932. "limit_type": 0,
  933. "limit_num": 0,
  934. "express_delivery": true,
  935. "store_mention": true,
  936. "attrInfo": {
  937. "id": 967,
  938. "product_id": 97,
  939. "suk": "干花组合6025【不含花瓶】,干花包",
  940. "stock": 562,
  941. "sales": 1,
  942. "price": "306.00",
  943. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/13/small_634a51ad34590eab005063742d086b87.jpg",
  944. "bar_code": "",
  945. "ot_price": "299.00",
  946. "volume": "0.00",
  947. "weight": "0.00",
  948. "brokerage": "0.00",
  949. "brokerage_two": "0.00",
  950. "type": 0,
  951. "unique": "fd6d98f3",
  952. "cost": "258.00",
  953. "quota": 0,
  954. "quota_show": 0,
  955. "vip_price": "0.00",
  956. "is_virtual": 0,
  957. "coupon_id": 0,
  958. "disk_info": ""
  959. }
  960. },
  961. "attrStatus": true,
  962. "vip_truePrice": 0,
  963. "costPrice": "258.00",
  964. "trueStock": 562,
  965. "truePrice": 306,
  966. "sum_price": "306.00",
  967. "price_type": "level",
  968. "is_valid": 1
  969. },
  970. {
  971. "id": 9670,
  972. "uid": 34391,
  973. "type": "0",
  974. "product_id": 102,
  975. "product_attr_unique": "02cce37e",
  976. "cart_num": 1,
  977. "add_time": 1666709927,
  978. "is_pay": 0,
  979. "is_del": 0,
  980. "is_new": 0,
  981. "combination_id": 0,
  982. "seckill_id": 0,
  983. "bargain_id": 0,
  984. "advance_id": 0,
  985. "status": 1,
  986. "productInfo": {
  987. "id": 102,
  988. "mer_id": 0,
  989. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/15/small_a79f5d2ea6bf0c3c11b2127332dfe2df.jpg",
  990. "recommend_image": "",
  991. "slider_image": [
  992. "https://demo26.crmeb.net/uploads/attach/2021/11/15/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg",
  993. "https://demo26.crmeb.net/uploads/attach/2021/11/15/7f46e98ece1920e1a4082dfc72bcd72a.jpg",
  994. "https://demo26.crmeb.net/uploads/attach/2021/11/15/bfb275263d02ab081b8670a752f2823f.jpg",
  995. "https://demo26.crmeb.net/uploads/attach/2021/11/15/e499a4dc489cda7b8d472cb3a3b348b7.jpg",
  996. "https://demo26.crmeb.net/uploads/attach/2021/11/15/06fa150a47163e973bb4806a380afaab.jpg"
  997. ],
  998. "store_name": "索尼(SONY)WH-CH510 无线立体声耳机 学生网课 白色",
  999. "store_info": "索尼(SONY)WH-CH510 无线立体声耳机 学生网课 白色",
  1000. "keyword": "耳机",
  1001. "bar_code": "",
  1002. "cate_id": "18,27,25",
  1003. "price": "299.00",
  1004. "vip_price": "0.00",
  1005. "ot_price": "349.00",
  1006. "postage": "0.00",
  1007. "unit_name": "件",
  1008. "sort": 0,
  1009. "sales": 3,
  1010. "stock": 297,
  1011. "is_show": 1,
  1012. "is_hot": 0,
  1013. "is_benefit": 0,
  1014. "is_best": 0,
  1015. "is_new": 0,
  1016. "is_virtual": 0,
  1017. "virtual_type": 0,
  1018. "add_time": 1636958921,
  1019. "is_postage": 0,
  1020. "is_del": 0,
  1021. "mer_use": 0,
  1022. "give_integral": "0.00",
  1023. "cost": "259.00",
  1024. "is_seckill": 0,
  1025. "is_bargain": null,
  1026. "is_good": 0,
  1027. "is_sub": 0,
  1028. "is_vip": 0,
  1029. "ficti": 0,
  1030. "browse": 0,
  1031. "code_path": "",
  1032. "soure_link": "",
  1033. "temp_id": 57,
  1034. "spec_type": 1,
  1035. "activity": "0,1,2,3",
  1036. "spu": "5757529716664",
  1037. "label_id": "0",
  1038. "video_link": "",
  1039. "command_word": "",
  1040. "recommend_list": "",
  1041. "vip_product": 0,
  1042. "presale": 0,
  1043. "presale_start_time": 0,
  1044. "presale_end_time": 0,
  1045. "presale_day": 0,
  1046. "logistics": "1,2",
  1047. "freight": 2,
  1048. "custom_form": "",
  1049. "is_limit": 0,
  1050. "limit_type": 0,
  1051. "limit_num": 0,
  1052. "express_delivery": true,
  1053. "store_mention": true,
  1054. "attrInfo": {
  1055. "id": 9,
  1056. "product_id": 102,
  1057. "suk": "黑色,CH510",
  1058. "stock": 98,
  1059. "sales": 2,
  1060. "price": "299.00",
  1061. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/15/small_a79f5d2ea6bf0c3c11b2127332dfe2df.jpg",
  1062. "bar_code": "",
  1063. "ot_price": "349.00",
  1064. "volume": "0.00",
  1065. "weight": "0.00",
  1066. "brokerage": "0.00",
  1067. "brokerage_two": "0.00",
  1068. "type": 0,
  1069. "unique": "02cce37e",
  1070. "cost": "259.00",
  1071. "quota": 0,
  1072. "quota_show": 0,
  1073. "vip_price": "0.00",
  1074. "is_virtual": 0,
  1075. "coupon_id": 0,
  1076. "disk_info": ""
  1077. }
  1078. },
  1079. "attrStatus": true,
  1080. "vip_truePrice": 0,
  1081. "costPrice": "259.00",
  1082. "trueStock": 98,
  1083. "truePrice": 299,
  1084. "sum_price": "299.00",
  1085. "price_type": "level",
  1086. "is_valid": 1
  1087. },
  1088. {
  1089. "id": 9669,
  1090. "uid": 34391,
  1091. "type": "0",
  1092. "product_id": 89,
  1093. "product_attr_unique": "89807c67",
  1094. "cart_num": 1,
  1095. "add_time": 1666709911,
  1096. "is_pay": 0,
  1097. "is_del": 0,
  1098. "is_new": 0,
  1099. "combination_id": 0,
  1100. "seckill_id": 0,
  1101. "bargain_id": 0,
  1102. "advance_id": 0,
  1103. "status": 1,
  1104. "productInfo": {
  1105. "id": 89,
  1106. "mer_id": 0,
  1107. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/small_2fbe723632427b0768df24c4f23c6cad.png",
  1108. "recommend_image": "",
  1109. "slider_image": [
  1110. "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/2fbe723632427b0768df24c4f23c6cad.png",
  1111. "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/64d188477292aa4ae2df8da7e63aca79.png"
  1112. ],
  1113. "store_name": "家居梵高系列联名款饭盒袋大容量手拎保温实用方便 星月夜饭盒袋",
  1114. "store_info": "",
  1115. "keyword": "家居梵高系列联名款饭盒袋大容量手拎保温实用方便 星月夜饭盒袋",
  1116. "bar_code": "",
  1117. "cate_id": "35",
  1118. "price": "350.00",
  1119. "vip_price": "0.00",
  1120. "ot_price": "300.00",
  1121. "postage": "0.00",
  1122. "unit_name": "件",
  1123. "sort": 553,
  1124. "sales": 19,
  1125. "stock": 185,
  1126. "is_show": 1,
  1127. "is_hot": 1,
  1128. "is_benefit": 0,
  1129. "is_best": 0,
  1130. "is_new": 0,
  1131. "is_virtual": 0,
  1132. "virtual_type": 0,
  1133. "add_time": 1636777038,
  1134. "is_postage": 0,
  1135. "is_del": 0,
  1136. "mer_use": 0,
  1137. "give_integral": "0.00",
  1138. "cost": "300.00",
  1139. "is_seckill": 0,
  1140. "is_bargain": null,
  1141. "is_good": 1,
  1142. "is_sub": 0,
  1143. "is_vip": 0,
  1144. "ficti": 0,
  1145. "browse": 0,
  1146. "code_path": "",
  1147. "soure_link": "",
  1148. "temp_id": 0,
  1149. "spec_type": 1,
  1150. "activity": "0,1,2,3",
  1151. "spu": "1015710267816",
  1152. "label_id": "",
  1153. "video_link": "",
  1154. "command_word": "",
  1155. "recommend_list": "",
  1156. "vip_product": 0,
  1157. "presale": 0,
  1158. "presale_start_time": 0,
  1159. "presale_end_time": 0,
  1160. "presale_day": 0,
  1161. "logistics": "1,2",
  1162. "freight": 2,
  1163. "custom_form": "[]",
  1164. "is_limit": 0,
  1165. "limit_type": 0,
  1166. "limit_num": 0,
  1167. "express_delivery": true,
  1168. "store_mention": true,
  1169. "attrInfo": {
  1170. "id": 1017,
  1171. "product_id": 89,
  1172. "suk": "梵高自画像饭盒",
  1173. "stock": 88,
  1174. "sales": 8,
  1175. "price": "350.00",
  1176. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/small_2fbe723632427b0768df24c4f23c6cad.png",
  1177. "bar_code": "",
  1178. "ot_price": "300.00",
  1179. "volume": "0.00",
  1180. "weight": "0.00",
  1181. "brokerage": "0.00",
  1182. "brokerage_two": "0.00",
  1183. "type": 0,
  1184. "unique": "89807c67",
  1185. "cost": "300.00",
  1186. "quota": 0,
  1187. "quota_show": 0,
  1188. "vip_price": "0.00",
  1189. "is_virtual": 0,
  1190. "coupon_id": 0,
  1191. "disk_info": ""
  1192. }
  1193. },
  1194. "attrStatus": true,
  1195. "vip_truePrice": 0,
  1196. "costPrice": "300.00",
  1197. "trueStock": 88,
  1198. "truePrice": 350,
  1199. "sum_price": "350.00",
  1200. "price_type": "level",
  1201. "is_valid": 1
  1202. }
  1203. ],
  1204. "invalid": [],
  1205. "deduction": {
  1206. "seckill_id": 0,
  1207. "bargain_id": 0,
  1208. "combination_id": 0,
  1209. "discount_id": 0
  1210. }
  1211. }
  1212. let cartList = cartListData
  1213. let valid = cartList.valid
  1214. let validList = that.$util.SplitArray(valid, that.cartList.valid);
  1215. let numSub = [{
  1216. numSub: true
  1217. }, {
  1218. numSub: false
  1219. }];
  1220. let numAdd = [{
  1221. numAdd: true
  1222. }, {
  1223. numAdd: false
  1224. }],
  1225. selectValue = [];
  1226. if (validList.length > 0) {
  1227. for (let index in validList) {
  1228. if (validList[index].cart_num == 1) {
  1229. validList[index].numSub = true;
  1230. } else {
  1231. validList[index].numSub = false;
  1232. }
  1233. let productInfo = validList[index].productInfo;
  1234. if (productInfo.hasOwnProperty('attrInfo') && validList[index].cart_num ==
  1235. validList[index].productInfo.attrInfo
  1236. .stock) {
  1237. validList[index].numAdd = true;
  1238. } else if (validList[index].cart_num == validList[index].productInfo
  1239. .stock) {
  1240. validList[index].numAdd = true;
  1241. } else {
  1242. validList[index].numAdd = false;
  1243. }
  1244. if (validList[index].attrStatus) {
  1245. validList[index].checked = true;
  1246. selectValue.push(validList[index].id);
  1247. } else {
  1248. validList[index].checked = false;
  1249. }
  1250. }
  1251. }
  1252. that.$set(that.cartList, 'valid', validList);
  1253. data.page = that.page + 1;
  1254. // that.goodsHidden = cartList.valid.length <= 0 ? false : true;
  1255. that.selectValue = selectValue;
  1256. let newArr = validList.filter(item => item.attrStatus);
  1257. that.isAllSelect = newArr.length == selectValue.length && newArr.length;
  1258. that.switchSelect();
  1259. }
  1260. that.loading = false;
  1261. this.canShow = true
  1262. uni.hideLoading();
  1263. // });
  1264. },
  1265. getInvalidList: function () {
  1266. let that = this;
  1267. if (this.loadendInvalid) return false;
  1268. if (this.loadingInvalid) return false;
  1269. let data = {
  1270. page: that.pageInvalid,
  1271. limit: that.limitInvalid,
  1272. status: 0
  1273. }
  1274. let resData = {
  1275. "valid": [],
  1276. "invalid": [],
  1277. "deduction": {
  1278. "seckill_id": 0,
  1279. "bargain_id": 0,
  1280. "combination_id": 0,
  1281. "discount_id": 0
  1282. }
  1283. }
  1284. // getCartList(data).then(res => {
  1285. let cartList = resData,
  1286. invalid = cartList.invalid,
  1287. loadendInvalid = invalid.length < that.limitInvalid;
  1288. let invalidList = that.$util.SplitArray(invalid, that.cartList.invalid);
  1289. that.$set(that.cartList, 'invalid', invalidList);
  1290. that.loadendInvalid = loadendInvalid;
  1291. that.loadTitleInvalid = loadendInvalid ? that.$t(`我也是有底线的`) : that.$t(`加载更多`);
  1292. that.pageInvalid = that.pageInvalid + 1;
  1293. that.loadingInvalid = false;
  1294. // }).catch(res => {
  1295. // that.loadingInvalid = false;
  1296. // that.loadTitleInvalid = that.$t(`加载更多`);
  1297. // })
  1298. },
  1299. getHostProduct: function () {
  1300. let that = this;
  1301. if (that.hotScroll) return
  1302. that.hotPage++
  1303. that.hotScroll = hot_res.length < that.hotLimit
  1304. that.hostProduct = that.hostProduct.concat(hot_res)
  1305. // getProductHot(
  1306. // that.hotPage,
  1307. // that.hotLimit,
  1308. // ).then(res => {
  1309. // that.hotPage++
  1310. // that.hotScroll = res.data.length < that.hotLimit
  1311. // that.hostProduct = that.hostProduct.concat(res.data)
  1312. // });
  1313. },
  1314. goodsOpen: function () {
  1315. let that = this;
  1316. that.goodsHidden = !that.goodsHidden;
  1317. },
  1318. goRouter(item) {
  1319. var pages = getCurrentPages();
  1320. var page = (pages[pages.length - 1]).$page.fullPath;
  1321. if (item.link == page) return
  1322. uni.switchTab({
  1323. url: item.link,
  1324. fail(err) {
  1325. uni.redirectTo({
  1326. url: item.link
  1327. })
  1328. }
  1329. })
  1330. },
  1331. manage: function () {
  1332. let that = this;
  1333. that.footerswitch = !that.footerswitch;
  1334. let arr1 = [];
  1335. let arr2 = [];
  1336. let newValid = that.cartList.valid.map(item => {
  1337. if (that.footerswitch) {
  1338. if (item.attrStatus) {
  1339. if (item.checked) {
  1340. arr1.push(item.id);
  1341. }
  1342. } else {
  1343. item.checked = false;
  1344. arr2.push(item);
  1345. }
  1346. } else {
  1347. if (item.checked) {
  1348. arr1.push(item.id);
  1349. }
  1350. }
  1351. return item;
  1352. });
  1353. that.cartList.valid = newValid;
  1354. if (that.footerswitch) {
  1355. that.isAllSelect = newValid.length === arr1.length + arr2.length;
  1356. } else {
  1357. that.isAllSelect = newValid.length === arr1.length;
  1358. }
  1359. that.selectValue = arr1;
  1360. that.switchSelect();
  1361. },
  1362. unsetCart: function () {
  1363. let that = this,
  1364. ids = [];
  1365. for (let i = 0, len = that.cartList.invalid.length; i < len; i++) {
  1366. ids.push(that.cartList.invalid[i].id);
  1367. }
  1368. cartDel(ids).then(res => {
  1369. that.$util.Tips({
  1370. title: that.$t(`清除成功`)
  1371. });
  1372. that.$set(that.cartList, 'invalid', []);
  1373. that.getCartNum();
  1374. }).catch(res => {
  1375. });
  1376. }
  1377. },
  1378. onReachBottom() {
  1379. let that = this;
  1380. if (that.loadend) {
  1381. that.getInvalidList();
  1382. }
  1383. if (that.cartList.valid.length == 0 && that.cartList.invalid.length == 0) {
  1384. that.getHostProduct();
  1385. }
  1386. }
  1387. }
  1388. </script>
  1389. <style scoped lang="scss">
  1390. .page-footer {
  1391. position: fixed;
  1392. bottom: 0;
  1393. z-index: 30;
  1394. display: flex;
  1395. align-items: center;
  1396. justify-content: space-around;
  1397. width: 100%;
  1398. height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  1399. height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  1400. box-sizing: border-box;
  1401. border-top: solid 1rpx #F3F3F3;
  1402. background-color: #fff;
  1403. box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
  1404. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  1405. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  1406. .foot-item {
  1407. display: flex;
  1408. width: max-content;
  1409. align-items: center;
  1410. justify-content: center;
  1411. flex-direction: column;
  1412. position: relative;
  1413. .count-num {
  1414. position: absolute;
  1415. display: flex;
  1416. justify-content: center;
  1417. align-items: center;
  1418. width: 40rpx;
  1419. height: 40rpx;
  1420. top: 0rpx;
  1421. right: -15rpx;
  1422. color: #fff;
  1423. font-size: 20rpx;
  1424. background-color: #FD502F;
  1425. border-radius: 50%;
  1426. padding: 4rpx;
  1427. }
  1428. }
  1429. .foot-item image {
  1430. height: 50rpx;
  1431. width: 50rpx;
  1432. text-align: center;
  1433. margin: 0 auto;
  1434. }
  1435. .foot-item .txt {
  1436. font-size: 24rpx;
  1437. &.active {}
  1438. }
  1439. }
  1440. .shoppingCart {
  1441. /* #ifdef H5 */
  1442. // padding-bottom: 0;
  1443. // padding-bottom: constant(safe-area-inset-bottom);
  1444. // padding-bottom: env(safe-area-inset-bottom);
  1445. /* #endif */
  1446. }
  1447. .shoppingCart .labelNav {
  1448. height: 76rpx;
  1449. padding: 0 30rpx;
  1450. font-size: 22rpx;
  1451. color: #8c8c8c;
  1452. position: fixed;
  1453. left: 0;
  1454. width: 100%;
  1455. box-sizing: border-box;
  1456. background-color: #f5f5f5;
  1457. z-index: 5;
  1458. top: 0;
  1459. }
  1460. .shoppingCart .labelNav .item .iconfont {
  1461. font-size: 25rpx;
  1462. margin-right: 10rpx;
  1463. }
  1464. .shoppingCart .nav {
  1465. width: 100%;
  1466. height: 80rpx;
  1467. background-color: #fff;
  1468. padding: 0 30rpx;
  1469. box-sizing: border-box;
  1470. font-size: 28rpx;
  1471. color: #282828;
  1472. position: fixed;
  1473. left: 0;
  1474. z-index: 5;
  1475. top: 76rpx;
  1476. }
  1477. .shoppingCart .nav .num {
  1478. margin-left: 12rpx;
  1479. }
  1480. .shoppingCart .nav .administrate {
  1481. font-size: 26rpx;
  1482. color: #282828;
  1483. width: 110rpx;
  1484. height: 46rpx;
  1485. border-radius: 6rpx;
  1486. border: 1px solid #a4a4a4;
  1487. }
  1488. .shoppingCart .noCart {
  1489. margin-top: 171rpx;
  1490. background-color: #fff;
  1491. padding-top: 0.1rpx;
  1492. }
  1493. .shoppingCart .noCart .pictrue {
  1494. width: 414rpx;
  1495. height: 336rpx;
  1496. margin: 78rpx auto 56rpx auto;
  1497. }
  1498. .shoppingCart .noCart .pictrue image {
  1499. width: 100%;
  1500. height: 100%;
  1501. }
  1502. .shoppingCart .list {
  1503. margin-top: 171rpx;
  1504. }
  1505. .shoppingCart .list .item {
  1506. padding: 25rpx 30rpx;
  1507. background-color: #fff;
  1508. margin-bottom: 15rpx;
  1509. }
  1510. .shoppingCart .list .item .picTxt {
  1511. width: 627rpx;
  1512. position: relative;
  1513. }
  1514. .shoppingCart .list .item .picTxt .pictrue {
  1515. width: 160rpx;
  1516. height: 160rpx;
  1517. }
  1518. .shoppingCart .list .item .picTxt .pictrue image {
  1519. width: 100%;
  1520. height: 100%;
  1521. border-radius: 6rpx;
  1522. }
  1523. .shoppingCart .list .item .picTxt .text {
  1524. width: 444rpx;
  1525. font-size: 28rpx;
  1526. color: #282828;
  1527. }
  1528. .shoppingCart .list .item .picTxt .text .reColor {
  1529. color: #999;
  1530. }
  1531. .shoppingCart .list .item .picTxt .text .reElection {
  1532. margin-top: 20rpx;
  1533. }
  1534. .shoppingCart .list .item .picTxt .text .reElection .title {
  1535. font-size: 24rpx;
  1536. }
  1537. .shoppingCart .list .item .picTxt .text .reElection .reBnt {
  1538. width: 120rpx;
  1539. height: 46rpx;
  1540. border-radius: 23rpx;
  1541. font-size: 26rpx;
  1542. }
  1543. .shoppingCart .list .item .picTxt .text .infor {
  1544. font-size: 24rpx;
  1545. color: #868686;
  1546. margin-top: 16rpx;
  1547. }
  1548. .shoppingCart .list .item .picTxt .text .money {
  1549. font-size: 32rpx;
  1550. color: var(--view-theme);
  1551. margin-top: 28rpx;
  1552. }
  1553. .shoppingCart .list .item .picTxt .carnum {
  1554. height: 47rpx;
  1555. position: absolute;
  1556. bottom: 7rpx;
  1557. right: 0;
  1558. }
  1559. .shoppingCart .list .item .picTxt .carnum view {
  1560. border: 1rpx solid #a4a4a4;
  1561. width: 66rpx;
  1562. text-align: center;
  1563. height: 100%;
  1564. line-height: 40rpx;
  1565. font-size: 28rpx;
  1566. color: #a4a4a4;
  1567. }
  1568. .shoppingCart .list .item .picTxt .carnum .reduce {
  1569. border-right: 0;
  1570. border-radius: 3rpx 0 0 3rpx;
  1571. }
  1572. .shoppingCart .list .item .picTxt .carnum .reduce.on {
  1573. border-color: #e3e3e3;
  1574. color: #dedede;
  1575. }
  1576. .shoppingCart .list .item .picTxt .carnum .plus {
  1577. border-left: 0;
  1578. border-radius: 0 3rpx 3rpx 0;
  1579. }
  1580. .shoppingCart .list .item .picTxt .carnum .plus.on {
  1581. border-color: #e3e3e3;
  1582. color: #dedede;
  1583. }
  1584. .shoppingCart .list .item .picTxt .carnum .num {
  1585. color: #282828;
  1586. }
  1587. .shoppingCart .invalidGoods {
  1588. background-color: #fff;
  1589. }
  1590. .shoppingCart .invalidGoods .goodsNav {
  1591. width: 100%;
  1592. height: 66rpx;
  1593. padding: 0 30rpx;
  1594. box-sizing: border-box;
  1595. font-size: 28rpx;
  1596. color: #282828;
  1597. }
  1598. .shoppingCart .invalidGoods .goodsNav .iconfont {
  1599. color: #424242;
  1600. font-size: 28rpx;
  1601. margin-right: 17rpx;
  1602. }
  1603. .shoppingCart .invalidGoods .goodsNav .del {
  1604. font-size: 26rpx;
  1605. color: #999;
  1606. }
  1607. .shoppingCart .invalidGoods .goodsNav .del .icon-shanchu1 {
  1608. color: #999;
  1609. font-size: 33rpx;
  1610. vertical-align: -2rpx;
  1611. margin-right: 8rpx;
  1612. }
  1613. .shoppingCart .invalidGoods .goodsList .item {
  1614. padding: 20rpx 30rpx;
  1615. border-top: 1rpx solid #f5f5f5;
  1616. }
  1617. .shoppingCart .invalidGoods .goodsList .item .invalid {
  1618. font-size: 22rpx;
  1619. color: #fff;
  1620. width: 70rpx;
  1621. height: 36rpx;
  1622. background-color: #aaa;
  1623. border-radius: 3rpx;
  1624. text-align: center;
  1625. line-height: 36rpx;
  1626. }
  1627. .shoppingCart .invalidGoods .goodsList .item .pictrue {
  1628. width: 140rpx;
  1629. height: 140rpx;
  1630. }
  1631. .shoppingCart .invalidGoods .goodsList .item .pictrue image {
  1632. width: 100%;
  1633. height: 100%;
  1634. border-radius: 6rpx;
  1635. }
  1636. .shoppingCart .invalidGoods .goodsList .item .text {
  1637. width: 433rpx;
  1638. font-size: 28rpx;
  1639. color: #999;
  1640. height: 140rpx;
  1641. }
  1642. .shoppingCart .invalidGoods .goodsList .item .text .name {
  1643. width: 100%;
  1644. }
  1645. .shoppingCart .invalidGoods .goodsList .item .text .infor {
  1646. font-size: 24rpx;
  1647. }
  1648. .shoppingCart .invalidGoods .goodsList .item .text .end {
  1649. font-size: 26rpx;
  1650. color: #bbb;
  1651. }
  1652. .shoppingCart .footer {
  1653. z-index: 999;
  1654. width: 100%;
  1655. height: 96rpx;
  1656. background-color: #fafafa;
  1657. position: fixed;
  1658. padding: 0 30rpx;
  1659. box-sizing: border-box;
  1660. border-top: 1rpx solid #eee;
  1661. bottom: 98rpx;
  1662. bottom: calc(98rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  1663. bottom: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  1664. }
  1665. .shoppingCart .footer.on {
  1666. // #ifndef H5
  1667. bottom: 0rpx;
  1668. // #endif
  1669. }
  1670. .shoppingCart .footer .checkAll {
  1671. font-size: 28rpx;
  1672. color: #282828;
  1673. margin-left: 16rpx;
  1674. }
  1675. // .shoppingCart .footer checkbox .wx-checkbox-input{background-color:#fafafa;}
  1676. .shoppingCart .footer .money {
  1677. font-size: 30rpx;
  1678. }
  1679. .shoppingCart .footer .placeOrder {
  1680. color: #fff;
  1681. font-size: 30rpx;
  1682. width: 226rpx;
  1683. height: 70rpx;
  1684. border-radius: 50rpx;
  1685. text-align: center;
  1686. line-height: 70rpx;
  1687. margin-left: 22rpx;
  1688. }
  1689. .shoppingCart .footer .button .bnt {
  1690. font-size: 28rpx;
  1691. color: #999;
  1692. border-radius: 50rpx;
  1693. border: 1px solid #999;
  1694. width: 160rpx;
  1695. height: 60rpx;
  1696. text-align: center;
  1697. line-height: 60rpx;
  1698. }
  1699. .shoppingCart .footer .button form~form {
  1700. margin-left: 17rpx;
  1701. }
  1702. .uni-p-b-96 {
  1703. height: 96rpx;
  1704. }
  1705. .uni-p-b-98 {
  1706. height: 100rpx;
  1707. /* 兼容 IOS<11.2 */
  1708. height: calc(100rpx + constant(safe-area-inset-bottom));
  1709. /* 兼容 IOS>11.2 */
  1710. height: calc(100rpx + env(safe-area-inset-bottom));
  1711. }
  1712. .emptyBox {
  1713. text-align: center;
  1714. padding-top: 20rpx;
  1715. .tips {
  1716. color: #aaa;
  1717. font-size: 26rpx;
  1718. }
  1719. image {
  1720. width: 414rpx;
  1721. height: 304rpx;
  1722. }
  1723. }
  1724. </style>