index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <template>
  2. <view class="container">
  3. <!-- 积分兑换 -->
  4. <view class="integral">
  5. <view class="integral_title flex_r flex_ac">
  6. <view class="inte_icon"></view>
  7. <view class="inte_text">积分兑换</view>
  8. </view>
  9. <view class="goods flex_r" v-for="(item, index) in list" :key="index">
  10. <image class="goods_img" :src="item.goodsThumbnailUrl" mode=""></image>
  11. <view class="goods_info flex_c flex_jc">
  12. <view class="goods_name ellipsis">{{ item.goodsName }}</view>
  13. <view class="msg">{{ item.integral }}消费金</view>
  14. <view
  15. class="info_btn flex_r flex_ac flex_jc"
  16. @tap="openConversion(item.goodsId)"
  17. >立即兑换</view
  18. >
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 积分兑换-end -->
  23. <!-- 兑换弹窗 -->
  24. <uni-popup type="center" ref="conversion">
  25. <view class="const_con">
  26. <image
  27. class="closePopup"
  28. src="/static/f_close.png"
  29. mode=""
  30. @tap="closePopup"
  31. ></image>
  32. <view class="const_head flex_r flex_ac flex_jc">请选择兑换方式</view>
  33. <view class="const_info">
  34. <view class="frist_info flex_r flex_wrap">
  35. <view
  36. class="frist_list flex_c mar_b30"
  37. v-for="(item, index) in way_list"
  38. :key="index"
  39. @tap="setCurrent(index)"
  40. >
  41. <view class="flex_r flex_ac">
  42. <image
  43. class="frist_img"
  44. :src="
  45. currrent == index
  46. ? '/static/img/xuanzhong_icon.png'
  47. : '/static/img/weixuanzhong_icon.png'
  48. "
  49. mode=""
  50. ></image>
  51. <view class="frist_text">{{ item.name }}</view>
  52. </view>
  53. <view class="surplus">剩余({{ item.Integral }}积分)</view>
  54. </view>
  55. </view>
  56. <view class="hint" v-if="isShow">积分不足请用余额或现金支付</view>
  57. <view class="pay_way flex_r flex_ac flex_wrap mar_t30" v-if="isShow">
  58. <view class="frist_list flex_c">
  59. <view class="flex_r flex_ac" @tap="setPayWay(0)">
  60. <image
  61. class="frist_img"
  62. :src="
  63. pay_way == 0
  64. ? '/static/img/xuanzhong_icon.png'
  65. : '/static/img/weixuanzhong_icon.png'
  66. "
  67. mode=""
  68. ></image>
  69. <view class="frist_text">余额</view>
  70. </view>
  71. </view>
  72. <view class="frist_list flex_c">
  73. <view class="flex_r flex_ac" @tap="setPayWay(1)">
  74. <image
  75. class="frist_img"
  76. :src="
  77. pay_way == 1
  78. ? '/static/img/xuanzhong_icon.png'
  79. : '/static/img/weixuanzhong_icon.png'
  80. "
  81. mode=""
  82. ></image>
  83. <view class="frist_text">现金</view>
  84. </view>
  85. </view>
  86. </view>
  87. <checkbox-group
  88. class="flex_r flex_ac flex_jc"
  89. @change="checkboxChange"
  90. >
  91. <label class="option_box mar_t30">
  92. <checkbox
  93. value="1"
  94. :checked="checked"
  95. color="#2DB389"
  96. style="transform: scale(0.7)"
  97. />
  98. 我已阅读同意<text @tap.stop="getProPage">《购买协议》</text>
  99. </label>
  100. </checkbox-group>
  101. <view class="conversion flex_r flex_ac flex_jc" @tap="confimConver"
  102. >确认兑换</view
  103. >
  104. </view>
  105. </view>
  106. </uni-popup>
  107. <!-- 兑换弹窗-end -->
  108. </view>
  109. </template>
  110. <script>
  111. let page = 1;
  112. let app = getApp();
  113. var appEv = app.$vm.$options;
  114. import uniPopup from "@/components/uni-popup/uni-popup.vue";
  115. export default {
  116. components: { uniPopup },
  117. data() {
  118. return {
  119. list: [], // 积分商品
  120. checked: false, //是否选中协议
  121. currrent: 0, // 选中的兑换方式
  122. pay_way: 0, //选中的支付方式
  123. isShow: false, // 是否显示现金支付
  124. goodsId: "", // 选中的商品Id
  125. };
  126. },
  127. onShow: function () {
  128. page = 1;
  129. this.list = [];
  130. this.loadData();
  131. },
  132. methods: {
  133. loadData: function () {
  134. this.loadGoods();
  135. this.integralMethodChange();
  136. },
  137. // 获取轮播图
  138. loadBacnner: function () {
  139. let that = this;
  140. const info = reqApi.integralLunBo();
  141. if (info) {
  142. info.then((res) => {
  143. if (res.data.status == 200) {
  144. that.imgArr = res.data.list;
  145. }
  146. });
  147. }
  148. },
  149. // 获取积分专区商品列表
  150. loadGoods: function () {
  151. let that = this;
  152. let data = {
  153. page: page,
  154. limit: 10,
  155. };
  156. const info = reqApi.getInteGoods(data);
  157. if (info) {
  158. info.then((res) => {
  159. if (res.data.status == 200) {
  160. let obj = res.data.goods;
  161. if (obj.length > 0) {
  162. for (var i in obj) {
  163. that.list.push(obj[i]);
  164. }
  165. } else {
  166. if (page == 1) {
  167. that.haveGoods = true;
  168. page = -1;
  169. } else {
  170. page = -1;
  171. appEv.errTips("暂无更多");
  172. }
  173. }
  174. } else {
  175. if (page == 1) {
  176. that.haveGoods = true;
  177. page = -1;
  178. } else {
  179. page = -1;
  180. appEv.errTips("暂无更多");
  181. }
  182. }
  183. });
  184. }
  185. },
  186. // 获取兑换方式
  187. integralMethodChange: function () {
  188. let that = this;
  189. const info = reqApi.integralMethodChange();
  190. if (info) {
  191. info.then((res) => {
  192. if (res.data.status == 200) {
  193. that.way_list = res.data.data;
  194. }
  195. });
  196. }
  197. },
  198. // 更改方式
  199. setCurrent: function (e) {
  200. this.currrent = e;
  201. this.pay_way = "";
  202. this.isShow = false;
  203. },
  204. // 更改支付方式
  205. setPayWay: function (e) {
  206. this.pay_way = e;
  207. },
  208. // 确认兑换
  209. confimConver: function () {
  210. let that = this;
  211. let isShow = this.isShow;
  212. let pay_way = this.pay_way;
  213. let checked = this.checked;
  214. let currrent = this.currrent;
  215. if (currrent === "") {
  216. appEv.errTips("请选择兑换方式");
  217. return false;
  218. }
  219. if (isShow && pay_way === "") {
  220. appEv.errTips("请选择支付方式");
  221. return false;
  222. }
  223. if (!checked) {
  224. appEv.errTips("请阅读并同意购买协议");
  225. return false;
  226. }
  227. let data = {
  228. goodsId: this.goodsId,
  229. xyType: 1,
  230. integralType: this.way_list[this.currrent].type,
  231. count: 1,
  232. };
  233. if (isShow) {
  234. data.jeType = this.pay_way == 0 ? 4 : 5;
  235. } else {
  236. data.jeType = 3;
  237. }
  238. const info = reqApi.integralClickExchange(data);
  239. if (info) {
  240. info.then((res) => {
  241. if (res.data.status == 200) {
  242. appEv.errTips(res.data.msg);
  243. let goodsId = that.goodsId;
  244. let count = 1;
  245. let goodsType = 5;
  246. let ojsType = 1;
  247. let payType = !isShow
  248. ? 3
  249. : isShow && pay_way == 0
  250. ? 4
  251. : isShow && pay_way == 1
  252. ? 5
  253. : isShow && that.way_list[that.currrent].Integral == 0
  254. ? 6
  255. : "";
  256. setTimeout(() => {
  257. uni.navigateTo({
  258. url:
  259. "/pages/to-pay-list/index?goodsId=" +
  260. goodsId +
  261. "&count=" +
  262. count +
  263. "&goodsType=" +
  264. goodsType +
  265. "&ojsType=" +
  266. ojsType +
  267. "&payType=" +
  268. payType,
  269. });
  270. }, 800);
  271. } else {
  272. appEv.errTips(res.data.msg);
  273. that.isShow = true;
  274. }
  275. });
  276. }
  277. },
  278. // 更改协议选中情况
  279. checkboxChange: function (e) {
  280. let index = e.detail.value.indexOf("1");
  281. if (index != -1) {
  282. this.checked = true;
  283. } else {
  284. this.checked = false;
  285. }
  286. },
  287. // 点击立即兑换打开弹窗
  288. openConversion: function (e) {
  289. this.goodsId = e;
  290. this.$refs.conversion.open();
  291. },
  292. // 关闭立即兑换弹窗
  293. closePopup: function () {
  294. this.$refs.conversion.close();
  295. },
  296. getProPage: function () {
  297. uni.navigateTo({
  298. url: "/pages/protocol/index?type=" + 4,
  299. });
  300. },
  301. },
  302. onShareAppMessage: function () {
  303. var path = "/pages/integral-list/index?agentId=1";
  304. if (app.globalData.systemUserInfo && app.globalData.systemUserInfo.userId) {
  305. path = path + "?agentId=" + app.globalData.systemUserInfo.userId;
  306. }
  307. var title = `让数字经济赋能美好生活!`;
  308. return {
  309. title: title,
  310. path: path,
  311. };
  312. },
  313. /**
  314. * 页面上拉触底事件的处理函数
  315. */
  316. onReachBottom: function () {
  317. if (page != -1) {
  318. var that = this;
  319. setTimeout(function () {
  320. ++page;
  321. that.loadData();
  322. }, 800);
  323. }
  324. },
  325. };
  326. </script>
  327. <style lang="scss" scoped>
  328. // 页面配置
  329. page {
  330. background: #f4f4f4;
  331. }
  332. .container {
  333. padding: 30rpx;
  334. box-sizing: border-box;
  335. }
  336. // 页面配置-end
  337. // 顶部广告图
  338. .banner_top {
  339. width: 100%;
  340. height: 360rpx;
  341. }
  342. // 顶部广告图-end
  343. // 积分兑换
  344. .integral {
  345. width: 100%;
  346. overflow: hidden;
  347. }
  348. .integral_title {
  349. width: 100%;
  350. overflow: hidden;
  351. padding: 30rpx 0;
  352. }
  353. .goods_info {
  354. width: calc(100% - 300rpx - 40rpx);
  355. overflow: hidden;
  356. }
  357. .goods_img {
  358. width: 300rpx;
  359. height: 208rpx;
  360. border-radius: 12rpx;
  361. margin-right: 40rpx;
  362. }
  363. .inte_icon {
  364. width: 22rpx;
  365. height: 22rpx;
  366. border-radius: 50%;
  367. border: 3rpx solid #1bbd89;
  368. box-sizing: border-box;
  369. }
  370. .goods_name {
  371. width: 100%;
  372. overflow: hidden;
  373. font-family: "SourceHanSansCN-Bold";
  374. font-size: 28rpx;
  375. color: #1a1a1a;
  376. }
  377. .inte_text {
  378. font-size: 32rpx;
  379. color: #232323;
  380. font-family: "SourceHanSansCN-Medium";
  381. font-weight: 500;
  382. line-height: 1;
  383. margin-left: 20rpx;
  384. }
  385. .msg {
  386. width: 100%;
  387. overflow: hidden;
  388. color: #18ba87;
  389. font-size: 26rpx;
  390. margin-top: 16rpx;
  391. margin-bottom: 22rpx;
  392. font-family: "SourceHanSansCN-Medium";
  393. }
  394. .goods {
  395. width: 100%;
  396. overflow: hidden;
  397. background: #fff;
  398. border-radius: 12rpx;
  399. margin-bottom: 18rpx;
  400. padding: 18rpx;
  401. box-sizing: border-box;
  402. align-items: initial;
  403. }
  404. .info_btn {
  405. width: 124rpx;
  406. height: 40rpx;
  407. background-color: #1bbd89;
  408. border-radius: 8rpx;
  409. color: #fff;
  410. font-size: 22rpx;
  411. font-family: "SourceHanSansCN-Bold";
  412. font-weight: bold;
  413. }
  414. // 积分兑换-end
  415. // 兑换弹窗
  416. .option_box {
  417. font-size: 26rpx;
  418. }
  419. .option_box text {
  420. color: #2db389;
  421. }
  422. .hint {
  423. font-size: 20rpx;
  424. color: #d54912;
  425. }
  426. .pay_way {
  427. width: 100%;
  428. overflow: hidden;
  429. }
  430. .frist_list {
  431. width: 50%;
  432. overflow: hidden;
  433. }
  434. .surplus {
  435. font-size: 22rpx;
  436. color: #a8a8a8;
  437. }
  438. .frist_text {
  439. font-size: 28rpx;
  440. color: #302f2f;
  441. }
  442. .frist_img {
  443. width: 35rpx;
  444. height: 35rpx;
  445. margin-right: 32rpx;
  446. }
  447. .frist_info {
  448. width: 100%;
  449. overflow: hidden;
  450. align-items: initial;
  451. }
  452. .closePopup {
  453. width: 42rpx;
  454. height: 42rpx;
  455. position: absolute;
  456. right: 0;
  457. top: -65rpx;
  458. }
  459. .const_con {
  460. width: 689rpx;
  461. border-radius: 10rpx;
  462. background: #fff;
  463. position: relative;
  464. }
  465. .const_info {
  466. width: 100%;
  467. overflow: hidden;
  468. padding: 30rpx 50rpx;
  469. box-sizing: border-box;
  470. }
  471. .const_head {
  472. width: 100%;
  473. height: 97rpx;
  474. border-bottom: 3rpx solid rgba(0, 0, 0, 0.15);
  475. font-size: 40rpx;
  476. color: #1bbd89;
  477. font-family: "SourceHanSansCN-Medium";
  478. }
  479. .conversion {
  480. width: 269rpx;
  481. height: 68rpx;
  482. background: #1bbe8a;
  483. font-family: "SourceHanSansCN-Medium";
  484. color: #fff;
  485. font-size: 32rpx;
  486. border-radius: 34rpx;
  487. margin: 40rpx auto 0;
  488. }
  489. // 兑换弹窗-end
  490. </style>