index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. <template>
  2. <block>
  3. <!-- z-paging插件:具体使用文档请看https://z-paging.zxlee.cn/ -->
  4. <z-paging
  5. auto-show-back-to-top
  6. back-to-top-bottom="300rpx"
  7. :auto="false"
  8. :paging-style="{ paddingBottom: 'constant(safe-area-inset-bottom)', paddingBottom: 'env(safe-area-inset-bottom)' }"
  9. ref="paging"
  10. v-model="dataList"
  11. @query="queryList"
  12. >
  13. <view class="homeIdx o-plr-24">
  14. <view class="l-flex-between o-mt-20">
  15. <view class="l-flex-RC">
  16. <u-icon name="map" class="c-color-8"></u-icon>
  17. <text class="c-color-8 u-line-1">{{ GETT_clientStatus.storeName }}</text>
  18. </view>
  19. <u-icon @click="toScan" name="scan" class="c-color-8" size="28"></u-icon>
  20. </view>
  21. <view class="o-mb-20" style="color: #ce2929;">图片仅供参考,具体以实物为准。</view>
  22. <view class="">
  23. <view class="l-flex-between l-flex-w">
  24. <view v-for="item in dataList" style="width:48%;" class="l-re l-boxShadow o-mb-20 c-bg-f o-plr-10 o-pb-10 o-pt-66 c-radius-10">
  25. <view class="l-flex-center">
  26. <u--image
  27. :width="GETT_miniProduct.includes(item.imgId) ? '200rpx' : '250rpx'"
  28. :height="GETT_miniProduct.includes(item.imgId) ? '200rpx' : '250rpx'"
  29. @click="goodsClick(item)"
  30. mode="aspectFit"
  31. :lazy-load="true"
  32. :fade="true"
  33. duration="450"
  34. :src="item.imgUrl"
  35. >
  36. <view slot="error" style="font-size: 24rpx;">加载失败</view>
  37. </u--image>
  38. </view>
  39. <view class="">
  40. <view class="o-mtb-10 c-color-8">{{ item.imgName }}</view>
  41. <view class="l-flex-between o-mb-10">
  42. <text class="c-text-12 c-color-MR">¥{{ item.goodsPrice }}</text>
  43. <!-- 如果优惠券总金额大于0,则显示预估到手价 -->
  44. <view v-if="GETT_home_totalCoupon > 0" class="estiPriceCon c-text-12 c-color-f l-flex-RC">
  45. <view class="estiPriceTxt c-text-12 o-ptb-10 o-plr-14">预估到手</view>
  46. <view class="estiPrice c-text-12 o-ptb-10 o-plr-14">¥{{ item.estiPrice }}</view>
  47. </view>
  48. </view>
  49. </view>
  50. <u-button v-if="item.showType !== 1" @click="addCart(item)" throttleTime="300" type="primary" shape="circle" size="normal" text="加入购物车"></u-button>
  51. <view
  52. :style="[headerStyle(item)]"
  53. class="l-ab l-flex-between o-w o-ptb-10 o-plr-10"
  54. style="left: 0;top: 0;
  55. border-top-right-radius: 10rpx;
  56. border-top-left-radius: 10rpx;"
  57. >
  58. <text class="c-text-12">{{ item.flavorName }}</text>
  59. <view class="l-flex-RC">
  60. <image
  61. class="o-mr-6"
  62. v-if="item.flavor.includes(1)"
  63. style="width: 30rpx;height: 30rpx;"
  64. src="/static/images/home/flavor/icon_milk.png"
  65. mode=""
  66. ></image>
  67. <image
  68. class="o-mr-6"
  69. v-if="item.flavor.includes(2)"
  70. style="width: 30rpx;height: 30rpx;"
  71. src="/static/images/home/flavor/icon_strawberry.png"
  72. mode=""
  73. ></image>
  74. <image
  75. class="o-mr-6"
  76. v-if="item.flavor.includes(3)"
  77. style="width: 30rpx;height: 30rpx;"
  78. src="/static/images/home/flavor/icon_orange.png"
  79. mode=""
  80. ></image>
  81. <image
  82. class="o-mr-6"
  83. v-if="item.flavor.includes(4)"
  84. style="width: 30rpx;height: 30rpx;"
  85. src="/static/images/home/flavor/icon_melon.png"
  86. mode=""
  87. ></image>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. <template #bottom>
  95. <view v-show="totalNums !== 0" class="l-boxShadow c-bg-f l-flex-between o-plr-24 o-ptb-20" style="width: 100%;height: 100rpx;">
  96. <view @click="toTabCar" class="l-re">
  97. <u-badge absolute :offset="[0, 0]" :value="totalNums"></u-badge>
  98. <u-icon size="40" name="shopping-cart"></u-icon>
  99. </view>
  100. <view class="c-color-1 c-text-16">
  101. 合计:
  102. <text class="c-text-16 c-color-MR">¥{{ totalPrice }}</text>
  103. </view>
  104. <view>
  105. <u-button
  106. v-if="GETT_loginInfos.phone"
  107. @click="toPayPop"
  108. throttleTime="2000"
  109. type="primary"
  110. shape="circle"
  111. size="normal"
  112. :text="`去支付(${totalNums})`"
  113. ></u-button>
  114. <u-button
  115. v-else
  116. open-type="getPhoneNumber"
  117. @getphonenumber="getPhone"
  118. type="primary"
  119. shape="circle"
  120. size="normal"
  121. :text="`去支付(${totalNums})`"
  122. ></u-button>
  123. </view>
  124. </view>
  125. <!-- 底部导航栏-占位符解决上拉刷新没显示加载更多的问题 -->
  126. <k-tabbar :fixed="false" :placeholder="false" :safeAreaInsetBottom="false" />
  127. </template>
  128. </z-paging>
  129. <!-- 支付弹窗 -->
  130. <k-payPop ref="kPayPopRef"></k-payPop>
  131. <!-- 支付提示弹窗 -->
  132. <u-modal @confirm="payShow = false" :show="payShow" title="提示" :content="payContent"></u-modal>
  133. <!-- 优惠券弹窗 -->
  134. <k-coupon ref="kCouponRef"></k-coupon>
  135. <!-- 领取优惠券弹窗 -->
  136. <u-overlay :show="coupPopShow">
  137. <view class="coupPopCon l-fixed o-w o-plr-100">
  138. <view class="coupPop l-boxShadow c-radius-10 o-w o-pb-50">
  139. <view class="headerCon o-w c-text-c c-text-b c-text-18 o-ptb-40" style="color: #926135;">送你一张优惠券</view>
  140. <!-- <view v-else class="headerCon o-w c-text-c c-text-b c-text-18 o-ptb-40" style="color: #926135;">你已领取优惠券</view> -->
  141. <view class="o-w c-text-c c-text-12 o-ptb-20" style="color: #926135;">每个用户只可领取一次</view>
  142. <view class="content o-w l-flex-center o-pt-30">
  143. <view class="contentCon c-text-c o-pb-20">
  144. <text class="c-text-40 c-text-b" style="color: #926135;">{{ GETT_home_coupon.split('J')[1] }}</text>
  145. <text class="rmbCls c-text-14 c-color-f o-ptb-10 o-plr-10" style="color: #926135;">元</text>
  146. </view>
  147. </view>
  148. <view class="o-w l-flex-center c-text-12 o-ptb-30" style="color: #926135;">全场商品满0.01元使用</view>
  149. <view class="o-w l-flex-center"><view @click="getCoupon" class="immedCls c-text-c c-color-f o-ptb-20">立即领取</view></view>
  150. </view>
  151. <view class="o-w l-flex-center o-mt-20"><u-icon @click="hideCoupPop" size="26" color="#fff" name="close-circle"></u-icon></view>
  152. </view>
  153. </u-overlay>
  154. <view v-if="showToast" class="l-flex-center l-fixed" style="width: 100vw;height: 100vh;z-index: 9999;">
  155. <view class="c-text-c c-text-16 c-color-f o-ptb-20 o-plr-50" style="background-color: #585858;border-radius: 10rpx;">
  156. <view style="line-height: 26px;">
  157. 此券每人限领一张
  158. </view>
  159. <view style="line-height: 26px;">
  160. 您已领取过,不能再领!
  161. </view>
  162. </view>
  163. </view>
  164. </block>
  165. </template>
  166. <script>
  167. // 导入登录方法
  168. import appLogin from '@/common/login.js';
  169. // 导入优惠券弹窗
  170. import kCoupon from '@/components/common/k-coupon/index.vue';
  171. // 导入支付弹窗
  172. import kPayPop from '@/components/common/k-payPop/index.vue';
  173. // 导入接口
  174. import { API_selectProductList, API_getPhone, API_getOpenid, API_getConpon,API_setDingYue } from '@/common/api.js';
  175. // 引入辅助函数
  176. import { mapGetters } from 'vuex';
  177. // 引入底部导航栏
  178. import kTabbar from '@/components/common/k-tabbar/k-tabbar.vue';
  179. // 引入商品数据
  180. import goodsList from '@/static/images/home/goods.js';
  181. export default {
  182. components: {
  183. kTabbar,
  184. kPayPop,
  185. kCoupon
  186. },
  187. data() {
  188. return {
  189. showToast:false,
  190. // 领取优惠券弹窗显示
  191. coupPopShow: false,
  192. // 用来解决单个商品购买联动问题
  193. copyData: [],
  194. // 支付提示弹窗
  195. payShow: false,
  196. payContent: false,
  197. // z-paging插件的主数据,用作列表渲染
  198. dataList: []
  199. };
  200. },
  201. computed: {
  202. // 获取vuex中购物车的数据
  203. $S_tabbar_shopCarts() {
  204. return this.$M_GS('common', '$S_tabbar_shopCarts');
  205. },
  206. // 使用辅助函数
  207. ...mapGetters([
  208. 'GETT_clientStatus',
  209. 'totalNums',
  210. 'totalPrice',
  211. 'isGetUserInfo',
  212. 'GETT_loginInfos',
  213. 'GETT_clientId',
  214. 'GETT_miniProduct',
  215. 'GETT_home_coupon',
  216. 'GETT_home_couponList',
  217. 'GETT_home_totalCoupon',
  218. 'GETT_home_hasReceCoup'
  219. ]),
  220. headerStyle() {
  221. return function(row) {
  222. let headerSye = {};
  223. switch (row.flavorName) {
  224. case '牛奶味':
  225. headerSye = {
  226. color: '#fff',
  227. backgroundColor: '#c8e5ec'
  228. };
  229. break;
  230. case '草莓味':
  231. headerSye = {
  232. color: '#fe796d',
  233. backgroundColor: '#fff5f4'
  234. };
  235. break;
  236. case '香橙味':
  237. headerSye = {
  238. color: '#fdd08f',
  239. backgroundColor: '#fff5e6'
  240. };
  241. break;
  242. case '蜜瓜味':
  243. headerSye = {
  244. color: '#a3d5f1',
  245. backgroundColor: '#ebf8ff'
  246. };
  247. break;
  248. case '混合口味':
  249. headerSye = {
  250. color: '#ccd77e',
  251. backgroundColor: '#f5f7e5'
  252. };
  253. break;
  254. }
  255. return headerSye;
  256. };
  257. }
  258. },
  259. methods: {
  260. // 点击隐藏优惠券弹窗
  261. hideCoupPop() {
  262. // 储存优惠券(控制弹窗的显示)
  263. this.$M_Cm('MUTA_SETCOUPON', '');
  264. this.coupPopShow = false;
  265. },
  266. // 初始化页面
  267. init(val) {
  268. if (val) {
  269. // 重新刷新页面数据
  270. this.$refs.paging.refresh();
  271. } else {
  272. // 空列表
  273. this.$refs.paging.complete([]);
  274. }
  275. },
  276. // 生成优惠券
  277. async getCoupon() {
  278. // 关闭弹窗
  279. this.coupPopShow = false;
  280. const param = {
  281. wxId: this.GETT_loginInfos.id,
  282. flag: this.GETT_home_coupon
  283. };
  284. const res = await API_getConpon(param, {
  285. catch: true
  286. });
  287. if(res.data === 1){
  288. this.showToast = true;
  289. setTimeout(()=>{
  290. this.showToast = false;
  291. },3000);
  292. }
  293. // 获取优惠券列表
  294. const hasCoupList = await this.$M_Dp('ACTI_SETCOUPONLIST');
  295. if (hasCoupList) {
  296. setTimeout(() => {
  297. // 先清空列表
  298. this.$refs.paging.complete([]);
  299. this.hideCoupPop();
  300. // 重新刷新页面数据
  301. this.$refs.paging.refresh();
  302. }, 200);
  303. }
  304. },
  305. // 点击商品
  306. goodsClick(row) {
  307. let curGoods = {};
  308. if (this.copyData.length > 0) {
  309. this.copyData.forEach(item => {
  310. if (item.imgId === row.imgId) {
  311. curGoods = uni.$u.deepClone(item);
  312. }
  313. });
  314. }
  315. this.$M_Cm('MUTA_SINGSHOPCARTS', curGoods);
  316. this.$M_Go(`/otherPages/home/singleBye/index`);
  317. },
  318. // 获取手机号
  319. async getPhone(e) {
  320. const { code } = e.detail;
  321. // 如果用户点击允许获取手机号
  322. if (!!code) {
  323. let param = {
  324. code,
  325. id: this.GETT_loginInfos.id
  326. };
  327. // 调用获取手机号的接口
  328. let res = await API_getPhone(param);
  329. // 把手机号信息存到vuex里面
  330. await this.$M_Cm('MUTA_GETOPENID', res);
  331. }
  332. this.toPayPop();
  333. },
  334. // 点击支付按钮
  335. toPayPop() {
  336. // 规定支付的商品数量不能超过5
  337. if (this.totalNums > 5) {
  338. this.payContent = '支付商品的数量不能超过5件,请到购物车页面减少数量后,重新支付!!!';
  339. this.payShow = true;
  340. return;
  341. }
  342. //询问是否订阅取餐通知
  343. this.dingyue();
  344. const payParam = {
  345. shopCarts: this.$S_tabbar_shopCarts,
  346. clientId: this.GETT_clientId,
  347. id: this.GETT_loginInfos.id
  348. };
  349. // 如果有优惠券要提醒用户去选择优惠券
  350. if (this.GETT_home_couponList.length > 0) {
  351. uni.showModal({
  352. title: '提示',
  353. confirmText: '去使用',
  354. cancelText: '不使用',
  355. confirmColor: '#3c9cff',
  356. content: `当前可使用优惠券${this.GETT_home_couponList.length}张。`,
  357. success: modelRes => {
  358. if (modelRes.confirm) {
  359. // 打开优惠券弹窗
  360. this.$refs.kCouponRef.popOpen(this.GETT_home_couponList, payParam, 1, this.totalPrice);
  361. } else {
  362. // 显示支付弹窗
  363. this.$refs.kPayPopRef.popOpen(payParam, 1);
  364. }
  365. }
  366. });
  367. } else {
  368. // 显示支付弹窗
  369. this.$refs.kPayPopRef.popOpen(payParam, 1);
  370. }
  371. },
  372. //询问是否订阅取餐通知
  373. dingyue(){
  374. var that = this;
  375. wx.requestSubscribeMessage({
  376. tmplIds: ['NVmdaK4MwygT63ME830pwM6wZt4eufxhBr6jlQ2XXJ4'],
  377. success(res) {
  378. var status = res.NVmdaK4MwygT63ME830pwM6wZt4eufxhBr6jlQ2XXJ4;
  379. if(status=='accept'){
  380. //通知后台该用户订阅了消息
  381. var id = that.GETT_loginInfos.id;
  382. console.log('id=', id);
  383. API_setDingYue( {id:id} ).then(res => {
  384. console.log('res', res);
  385. });
  386. }
  387. console.log('授权成功');
  388. }
  389. })
  390. },
  391. // 方式二、直接下小程序首页扫码的
  392. // 点击扫码图标
  393. toScan() {
  394. // 只允许通过相机扫码
  395. uni.scanCode({
  396. onlyFromCamera: true,
  397. success: async codeRes => {
  398. // 初始化vuxe中优惠券数据
  399. this.$M_Cm('MUTA_SETCOUPON', '');
  400. this.$M_Cm('MUTA_SETCOUPONLIST', []);
  401. // 如果扫的是小程序码
  402. if (codeRes.scanType === 'WX_CODE') {
  403. // 获取到机器码和优惠券
  404. const clientIdAndCoup = codeRes.path.split('=')[1];
  405. // 获取机器码
  406. const clientId = clientIdAndCoup.split('-')[0];
  407. // 获取优惠券
  408. const coupon = clientIdAndCoup.split('-')[1];
  409. // 如果扫描的小程序有机器编码
  410. if (clientId) {
  411. // 登录
  412. const appLoginData = await appLogin({ clientId, flag: coupon }, true);
  413. if (appLoginData) {
  414. // // 重新刷新页面数据
  415. this.$refs.paging.refresh();
  416. } else {
  417. // 如果有机器联系人
  418. if (this.GETT_clientStatus.contactName) {
  419. // 并且弹窗
  420. this.contactDailog();
  421. } else {
  422. // 如果没有用户信息,提示用户重新扫码
  423. this.scanCodeDialog();
  424. }
  425. }
  426. } else {
  427. // 如果有机器联系人
  428. if (this.GETT_clientStatus.contactName) {
  429. // 并且弹窗
  430. this.contactDailog();
  431. } else {
  432. // 如果没有用户信息,提示用户重新扫码
  433. this.scanCodeDialog();
  434. }
  435. }
  436. }
  437. // 如果扫的是二维码
  438. else if (codeRes.scanType === 'QR_CODE') {
  439. let clientId = codeRes.result;
  440. // 如果扫描的小程序有机器编码
  441. if (clientId) {
  442. // 登录
  443. const appLoginData = await appLogin({ clientId, flag: '' }, true);
  444. if (appLoginData) {
  445. // // 重新刷新页面数据
  446. this.$refs.paging.refresh();
  447. } else {
  448. // 如果有机器联系人
  449. if (this.GETT_clientStatus.contactName) {
  450. // 并且弹窗
  451. this.contactDailog();
  452. } else {
  453. // 如果没有用户信息,提示用户重新扫码
  454. this.scanCodeDialog();
  455. }
  456. }
  457. } else {
  458. // 如果有机器联系人
  459. if (this.GETT_clientStatus.contactName) {
  460. // 并且弹窗
  461. this.contactDailog();
  462. } else {
  463. // 如果没有用户信息,提示用户重新扫码
  464. this.scanCodeDialog();
  465. }
  466. }
  467. } else {
  468. // 如果扫描的是其他码,提示用户重新扫码
  469. this.scanCodeDialog();
  470. }
  471. }
  472. });
  473. },
  474. // 扫描小程序码弹窗提示
  475. scanCodeDialog() {
  476. uni.showModal({
  477. title: '提示',
  478. confirmText: '确定',
  479. confirmColor: '#3c9cff',
  480. content: '请扫描机器上的小程序码或二维码!!!',
  481. success: modelRes => {
  482. if (modelRes.confirm) {
  483. // 直接跳转扫码界面
  484. this.toScan();
  485. }
  486. }
  487. });
  488. },
  489. // 联系人弹窗
  490. contactDailog() {
  491. // 如果没有机器编码就提示联系管理员
  492. uni.showModal({
  493. title: '当前设备处于关机状态,请联系机主后重新扫码。',
  494. confirmText: '拨打电话',
  495. confirmColor: '#3c9cff',
  496. content: `联系人:${this.GETT_clientStatus.contactName},联系电话:${this.GETT_clientStatus.contactPhone}`,
  497. success: modelRes => {
  498. if (modelRes.confirm) {
  499. uni.makePhoneCall({
  500. phoneNumber: this.GETT_clientStatus.contactPhone
  501. });
  502. }
  503. }
  504. });
  505. },
  506. // 点击支付按钮
  507. toTabCar() {
  508. this.$M_Dp('ACTI_TABIDX', 1);
  509. },
  510. // 获取小程序个人信息
  511. getUserInfo() {
  512. return new Promise((resolve, reject) => {
  513. uni.getUserProfile({
  514. desc: '用户我的页面展示效果',
  515. success: res => {
  516. if (res.errMsg === 'getUserProfile:ok') {
  517. const { nickName, avatarUrl } = res.userInfo;
  518. let param = {
  519. nickName,
  520. avatarUrl
  521. };
  522. this.$M_Cm('MUTA_AVATARNICK', param);
  523. resolve(true);
  524. } else {
  525. resolve(false);
  526. }
  527. },
  528. fail: err => {
  529. resolve(false);
  530. }
  531. });
  532. });
  533. },
  534. // 点击加入购物车
  535. async addCart(row) {
  536. // 增加用户体验
  537. uni.showLoading({
  538. title: '请稍等'
  539. });
  540. setTimeout(() => {
  541. uni.hideLoading();
  542. }, 200);
  543. // 看有vuex没有小程序个人信息,没有调用微信接口获取
  544. let isGetUserInfo = true;
  545. if (!this.isGetUserInfo) {
  546. isGetUserInfo = await this.getUserInfo();
  547. }
  548. if (!isGetUserInfo) {
  549. return;
  550. }
  551. // 加入购物车初始状态都是选中状态
  552. row['isCheck'] = true;
  553. // 获取vuxe购物车数据
  554. let shopCarts = this.$S_tabbar_shopCarts;
  555. // 如果不存在imgId这个属性,则创建
  556. if (!shopCarts[row['imgId']]) {
  557. // 给优惠码和优惠价的列表添加一个0值
  558. row.codeList.push(0);
  559. row.discountList.push(0);
  560. // 用$M_Extend继承row创建新对象并赋值给shopCarts的属性
  561. shopCarts[row['imgId']] = this.$M_Extend(row, {
  562. nums: 1
  563. });
  564. } else {
  565. // 如果存在imgId这个属性,则数量+1,总数totalPrice=价格goodsPrice*数量nums
  566. let nums = shopCarts[row['imgId']]['nums'] + 1;
  567. // $M_Big用来计算总数量的方法(具体用法请看common)
  568. row['totalPrice'] = this.$M_Big(row['goodsPrice'])
  569. .mul(nums)
  570. .toNumber();
  571. // 给优惠码和优惠价的列表添加一个0值
  572. row.codeList.push(0);
  573. row.discountList.push(0);
  574. shopCarts[row['imgId']] = this.$M_Extend(row, {
  575. nums
  576. });
  577. }
  578. // 修改vuex购物车数据
  579. this.$M_Dp('ACTI_SHOPCARTS', shopCarts);
  580. },
  581. // z-paging插件分页的方法
  582. async queryList(pageNo, pageSize) {
  583. // 如果是关机状态
  584. if (!this.GETT_clientStatus.startStatus) {
  585. this.$refs.paging.complete([]);
  586. // 如果是扫码进来的肯定会有机器的联系方式
  587. if (this.GETT_clientStatus.contactName) {
  588. // 并且弹窗
  589. this.contactDailog();
  590. } else {
  591. // 如果没有用户信息,提示用户重新扫码
  592. this.scanCodeDialog();
  593. }
  594. return;
  595. }
  596. // 如果存在优惠券要弹出优惠券窗口
  597. if (!!this.GETT_home_coupon) {
  598. this.coupPopShow = true;
  599. }
  600. let param = {
  601. clientId: this.GETT_clientId,
  602. size: pageSize,
  603. current: pageNo
  604. };
  605. // 发起获取商品类表请求
  606. API_selectProductList(param).then(res => {
  607. const { records } = res;
  608. if (records.length > 0) {
  609. goodsList.forEach(item => {
  610. records.forEach(item1 => {
  611. // 给前台数据赋值接口数组
  612. if (item1.no === item.imgId) {
  613. // 商品id
  614. item1.imgId = item.imgId;
  615. // 商品名字
  616. item1.imgName = item.imgName;
  617. // 商品图片
  618. item1.imgUrl = item.imgUrl;
  619. // 单价
  620. item1.goodsPrice = item1.rmbPrice;
  621. // 总价格
  622. item1.totalPrice = item1.rmbPrice;
  623. // 购物车对应商品是否选中
  624. item1.isCheck = true;
  625. // 优惠码
  626. item1.codeList = [];
  627. // 优惠价格
  628. item1.discountList = [];
  629. // 商品口味
  630. item1.flavorName = item.flavorName;
  631. item1.flavor = item.flavor;
  632. // 商品数量
  633. item1.nums = 1;
  634. }
  635. // 根据优惠券总数,计算出每件商品的预估到手价
  636. if (this.GETT_home_totalCoupon > 0) {
  637. // 预估到手价
  638. const estiPrice = this.$M_Big(item1.rmbPrice)
  639. .sub(this.GETT_home_totalCoupon)
  640. .toNumber();
  641. // 预估到手价最低也只能是0
  642. if (estiPrice <= 0) {
  643. item1.estiPrice = 0.01;
  644. } else {
  645. item1.estiPrice = estiPrice;
  646. }
  647. }
  648. });
  649. });
  650. }
  651. // this.$refs.paging.complete(records);
  652. // this.copyData = uni.$u.deepClone(records);
  653. var data = this.copyData;
  654. for(var i=0;i<records.length;i++){
  655. data.push(records[i]);
  656. }
  657. this.$refs.paging.complete(data);
  658. this.copyData = data;
  659. console.log('data=', data);
  660. });
  661. }
  662. }
  663. };
  664. </script>
  665. <style lang="scss" scoped>
  666. .homeIdx {
  667. .estiPriceCon {
  668. .estiPriceTxt {
  669. position: relative;
  670. color: #ff9900;
  671. background-color: #fff5f4;
  672. border-right: 1px solid #fff;
  673. }
  674. .estiPrice {
  675. background-color: #f15c34;
  676. border-top-right-radius: 10rpx;
  677. border-bottom-right-radius: 10rpx;
  678. }
  679. }
  680. }
  681. .coupPopCon {
  682. left: 0;
  683. top: 10vh;
  684. height: 100vh;
  685. z-index: 10071;
  686. .coupPop {
  687. background-color: #ffedd8;
  688. .headerCon {
  689. border-bottom: 2rpx dashed #d59035;
  690. }
  691. .content {
  692. .contentCon {
  693. width: 60%;
  694. border-bottom: 2rpx solid #d59035;
  695. .rmbCls {
  696. // background-color: #926135;
  697. border-radius: 50%;
  698. }
  699. }
  700. }
  701. .immedCls {
  702. width: 60%;
  703. background-color: #ff4b4a;
  704. border-radius: 40rpx;
  705. }
  706. }
  707. }
  708. </style>