productToDay.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <view class="container">
  3. <!-- 商品列表 -->
  4. <view class="goods_con flex_r flex_ac flex_wrap">
  5. <view class="goods" v-for="(item,index) in goods" :key="index" @tap="NavToGoodsDetail(item.id)">
  6. <image class="goods_img" :src="item.original_img" mode=""></image>
  7. <view class="goods_info">
  8. <view class="info_title">{{item.goods_name}}</view>
  9. <!-- <view class="info_msg ellipsis">{{item.goodsMsg}}</view> -->
  10. <view class="info_option flex_r flex_ac flex_jb">
  11. <view class="info_price"><text>¥</text>{{item.price}}</view>
  12. <!-- <image class="info_cart" src="/static/cart.png" mode="" @tap.stop="OpenShopping(index)"></image> -->
  13. </view>
  14. <view class="info_hint">赠送{{item.give_integral ? item.give_integral + '批发积分' : item.give_cha_bao + '茶宝'}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <!-- 商品列表-end -->
  19. <!-- 购买或加入购物车弹窗 -->
  20. <uni-popup ref="shopping" type="bottom">
  21. <view class="shopping">
  22. <view class="close_con flex_r flex_je">
  23. <image class="close_img" src="/static/close.png" @tap="closeBtn" mode=""></image>
  24. </view>
  25. <view class="goods_infos flex_r">
  26. <image class="goods_imgs" :src="goodsIndex.goodsThumbnailUrl" mode=""></image>
  27. <view class="goods_cons flex_c flex_jb">
  28. <view class="shop_names">{{goodsIndex.goodsName}}</view>
  29. <view class="goods_msg">{{'¥' + goodsIndex.price}}</view>
  30. <view class="num_con flex_r flex_je">
  31. <uni-number-box :min="1" @change="bindChange" :value="buyNum"></uni-number-box>
  32. </view>
  33. </view>
  34. </view>
  35. <checkbox-group class="flex_r flex_ac flex_jc" @change="checkboxChange">
  36. <label class="option_box">
  37. <checkbox value="1" :checked="checked" color="#2DB389" style="transform:scale(0.7)" /> 我已阅读同意<text @tap.stop="getProPage">《购买协议》</text>
  38. </label>
  39. </checkbox-group>
  40. <view class="confim flex_r flex_ac flex_jc" @tap="ToPayPage">确定</view>
  41. </view>
  42. </uni-popup>
  43. <!-- 购买或加入购物车弹窗-end -->
  44. </view>
  45. </template>
  46. <script>
  47. let page = 1;
  48. let app = getApp();
  49. var appEv = app.$vm.$options;
  50. // let reqApi = new ReqApi();
  51. // import { ReqApi } from "@/utils/reqTools.js";
  52. import { get, post, u_post } from "@/request/api.js";
  53. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  54. export default {
  55. components: { uniPopup },
  56. data() {
  57. return {
  58. goods: [], // 商品列表
  59. goodsIndex: '', // 选中猜你喜欢的下标
  60. buyNum: 1, // 购买数量
  61. checked: false, // 是否同意协议
  62. type: '',
  63. };
  64. },
  65. onLoad(e) {
  66. this.type = e.type
  67. },
  68. onShow() {
  69. page = 1;
  70. this.goods = [];
  71. this.loadData()
  72. },
  73. methods: {
  74. loadData() {
  75. let that = this;
  76. let data = {
  77. page: page,
  78. type: this.type
  79. }
  80. post("goods/goodsList", data).then(res => {
  81. if (res.code === 0) {
  82. let obj = res.data.data
  83. if(page == 1) that.goods = []
  84. if (obj.length > 0) {
  85. obj.forEach(e => {
  86. that.goods.push(e)
  87. });
  88. } else {
  89. page = -1;
  90. appEv.errTips('暂无更多')
  91. }
  92. } else {
  93. page = -1;
  94. appEv.errTips('暂无更多')
  95. }
  96. })
  97. },
  98. // 跳转到商品详情页
  99. NavToGoodsDetail(id, type) {
  100. uni.navigateTo({
  101. url: '/pages/product/p_details?id=' + id + '&type=' + this.type
  102. })
  103. },
  104. // 打开加入购物车窗口
  105. OpenShopping(index) {
  106. this.checked = false
  107. this.goodsIndex = this.goods[index]
  108. this.$refs.shopping.open()
  109. },
  110. // 购买数量更改
  111. bindChange: function(e) {
  112. this.buyNum = e;
  113. },
  114. // 点击关闭弹窗
  115. closeBtn: function() {
  116. this.$refs.shopping.close()
  117. },
  118. // 点击同意协议
  119. checkboxChange: function(e) {
  120. let index = e.detail.value.indexOf('1');
  121. if (index != -1) {
  122. this.checked = true
  123. } else {
  124. this.checked = false
  125. }
  126. },
  127. // 点击添加购物车
  128. ToPayPage: function() {
  129. if (!this.checked) {
  130. appEv.errTips('请勾选同意购买协议')
  131. return false
  132. }
  133. let that = this;
  134. let data = {
  135. goodsId: this.goodsIndex.goodsId,
  136. buyCount: this.buyNum,
  137. specialArea: 1
  138. }
  139. const info = reqApi.conShoppingCart(data)
  140. if (info) {
  141. info.then(res => {
  142. if (res.data.status == 200) {
  143. appEv.errTips('添加成功')
  144. that.checked = false
  145. that.buyNum = 1
  146. that.$refs.shopping.close()
  147. } else {
  148. appEv.errTips(res.data.msg)
  149. }
  150. })
  151. }
  152. },
  153. getProPage: function() {
  154. uni.navigateTo({
  155. url: '/pages/protocol/index?type=' + 1
  156. })
  157. }
  158. },
  159. onShareAppMessage: function() {
  160. let userinfo = uni.getStorageSync('userinfo');
  161. var path = '/pages/product/productRetail?agentId=1';
  162. if (userinfo.user_id) {
  163. path = '/pages/product/productRetail?agentId=' + userinfo.user_id;
  164. }
  165. var title = `让数字经济赋能美好生活!`;
  166. return {
  167. title: title,
  168. path: path
  169. }
  170. },
  171. /**
  172. * 页面上拉触底事件的处理函数
  173. */
  174. onReachBottom: function() {
  175. if (page != -1) {
  176. var that = this;
  177. setTimeout(function() {
  178. ++page;
  179. that.loadData();
  180. }, 800);
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="scss">
  186. // 页面配置
  187. page {
  188. background: #F4F4F4;
  189. }
  190. .container {
  191. padding: 22rpx 30rpx;
  192. box-sizing: border-box;
  193. }
  194. // 页面配置-end
  195. // 商品列表
  196. .goods:nth-child(2n) {
  197. margin-right: 0;
  198. }
  199. .info_cart {
  200. width: 46rpx;
  201. height: 45rpx;
  202. }
  203. .goods_con {
  204. width: 100%;
  205. overflow: hidden;
  206. }
  207. .info_hint {
  208. font-size: 22rpx;
  209. color: #787878;
  210. }
  211. .info_option {
  212. width: 100%;
  213. overflow: hidden;
  214. }
  215. .goods_img {
  216. width: 100%;
  217. height: 232rpx;
  218. display: block;
  219. }
  220. .info_msg {
  221. font-size: 24rpx;
  222. color: #787878;
  223. margin-top: 8rpx;
  224. }
  225. .goods_info {
  226. padding: 20rpx 16rpx;
  227. width: 100%;
  228. box-sizing: border-box;
  229. }
  230. .info_price {
  231. font-size: 32rpx;
  232. color: #18BB87;
  233. font-family: "SourceHanSansCN-Bold";
  234. }
  235. .info_title {
  236. font-size: 28rpx;
  237. color: #1B1A1A;
  238. font-family: "SourceHanSansCN-Bold";
  239. font-weight: bold;
  240. }
  241. .info_price text {
  242. font-size: 22rpx;
  243. color: #18BB87;
  244. font-family: "SourceHanSansCN-Bold";
  245. font-weight: bold;
  246. }
  247. .goods {
  248. width: calc((100% - 22rpx) / 2);
  249. overflow: hidden;
  250. margin-right: 22rpx;
  251. margin-bottom: 22rpx;
  252. background: #fff;
  253. border-radius: 12rpx;
  254. }
  255. // 商品列表-end
  256. // 购买或加入购物车弹窗
  257. .option_box text {
  258. color: #2DB389;
  259. }
  260. .goods_raido {
  261. margin-right: 180rpx;
  262. }
  263. .close_img {
  264. width: 36rpx;
  265. height: 36rpx;
  266. }
  267. .option_box {
  268. font-size: 26rpx;
  269. margin-top: 80rpx;
  270. }
  271. .goods_raido:nth-last-child(1) {
  272. margin-right: 0;
  273. }
  274. .num_con {
  275. width: 100%;
  276. overflow: hidden;
  277. padding-bottom: 3rpx;
  278. }
  279. .goods_option {
  280. width: 100%;
  281. overflow: hidden;
  282. padding-top: 50rpx;
  283. }
  284. .close_con {
  285. width: 100%;
  286. overflow: hidden;
  287. margin-bottom: 35rpx;
  288. }
  289. .raido_text {
  290. font-size: 26rpx;
  291. color: #545454;
  292. margin-left: 30rpx;
  293. }
  294. .goods_cons {
  295. width: calc(100% - 202rpx - 30rpx);
  296. overflow: hidden;
  297. }
  298. .goods_imgs {
  299. width: 202rpx;
  300. height: 183rpx;
  301. margin-right: 30rpx;
  302. border-radius: 12rpx;
  303. }
  304. .confim {
  305. width: 100%;
  306. height: 60rpx;
  307. border-radius: 30rpx;
  308. background: #2DB389;
  309. color: #fff;
  310. font-size: 26rpx;
  311. margin-top: 44rpx;
  312. }
  313. .shopping {
  314. width: 100%;
  315. overflow: hidden;
  316. padding: 20rpx;
  317. box-sizing: border-box;
  318. border-radius: 30rpx 30rpx 0 0;
  319. background: #fff;
  320. }
  321. .goods_infos {
  322. width: 100%;
  323. overflow: hidden;
  324. align-items: inherit;
  325. padding-bottom: 48rpx;
  326. border-bottom: 3rpx solid rgba(0, 0, 0, .12);
  327. }
  328. .shop_names {
  329. width: 100%;
  330. overflow: hidden;
  331. font-family: "SourceHanSansCN-Bold";
  332. font-weight: bold;
  333. color: #1B1B1B;
  334. font-size: 32rpx;
  335. }
  336. .goods_msg {
  337. width: 100%;
  338. overflow: hidden;
  339. font-size: 28rpx;
  340. color: #18BB88;
  341. font-family: "SourceHanSansCN-Medium";
  342. font-weight: 500;
  343. }
  344. .raido_img {
  345. width: 39rpx;
  346. height: 35rpx;
  347. background: url(~@/static/img/weixuanzhong.png);
  348. background-repeat: no-repeat;
  349. background-size: 35rpx 35rpx;
  350. background-position: center center;
  351. }
  352. .raido_box {
  353. background: url(~@/static/img/consent.png);
  354. background-repeat: no-repeat;
  355. background-size: 39rpx 35rpx;
  356. background-position: center center;
  357. }
  358. // 购买或加入购物车弹窗-end
  359. </style>