index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <app-layout>
  3. <view class="index" v-show="loading">
  4. <view class="search dir-left-nowrap cross-center">
  5. <view class="input dir-left-nowrap main-center cross-center" @click="navigator('/plugins/pick/search/search')">
  6. <image class="search-img" src="/static/image/icon/search.png"></image>
  7. <text class="search-text">搜索</text>
  8. </view>
  9. </view>
  10. <view class="billing" :style="{backgroundImage: `url(${background})`}">
  11. <view class="rule" @click="goRoute()">
  12. 活动规则
  13. </view>
  14. </view>
  15. <view class="activity" :style="{background: form.bg.color, color: form.text.color}" v-if="Object.keys(activity).length>0">
  16. {{activity.rule_price}}元,任选{{activity.rule_num}}件
  17. </view>
  18. <view class="list">
  19. <view class="item dir-left-nowrap" v-for="(item) in list" :key="item.id" @click="navigator('/plugins/pick/detail/detail?goods_id=' + item.id)">
  20. <view v-if="item.goods_stock == 0 && appSetting.is_show_stock === 1" class="out-dialog">
  21. <image :src="appSetting.is_use_stock == 1 ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  22. </view>
  23. <image class="image" :src="item.cover_pic"></image>
  24. <view class="content dir-top-nowrap main-between">
  25. <text class="name t-omit-two">{{item.name}}</text>
  26. <view class="information dir-left-nowrap main-between cross-bottom">
  27. <view class="num">
  28. <view class="value">
  29. <text class="price" :class="getTheme + '-m-text ' + getTheme">¥{{item.price}}</text>
  30. <text class="original_price">¥{{item.original_price}}</text>
  31. </view>
  32. <text class="sales" v-if="item.is_negotiable != 1 && isShowSalesNum == 1">{{item.sales}}</text>
  33. </view>
  34. <view>
  35. <view class="go-button" :class="getTheme + '-m-back ' + getTheme" >去凑单</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view v-if="list.length === 0">
  42. <app-no-goods background="" title="没有任何活动商品哦~"></app-no-goods>
  43. </view>
  44. <view v-if="list.length > 0" class="safe-area-inset-bottom u-bottom-fixed">
  45. <view class="generate dir-left-nowrap main-center cross-center"
  46. @click="navigator('/plugins/pick/pond/pond?rule_num='+ activity.rule_num + '&pick_activity_id=' + activity.id)">
  47. <image class="generate-img" src="../image/pond.png" :class="getTheme + '-m-back ' + getTheme"></image>
  48. <text class="generate-text" :class="getTheme + '-m-text ' + getTheme">生成凑单</text>
  49. <view class="pond-length" :class="getTheme + '-m-back ' + getTheme" v-if="storage > 0">{{storage | getStorage }}</view>
  50. </view>
  51. </view>
  52. </view>
  53. </app-layout>
  54. </template>
  55. <script>
  56. import appNoGoods from '../../../components/page-component/app-no-goods/app-no-goods.vue';
  57. import {mapGetters, mapState} from "vuex";
  58. export default {
  59. name: "index",
  60. data() {
  61. return {
  62. list: [],
  63. background: '',
  64. form: {
  65. bg: {
  66. color: ''
  67. },
  68. text: {
  69. color: ''
  70. }
  71. },
  72. activity: {
  73. rule_price: 0,
  74. rule_num: 0
  75. },
  76. page: 1,
  77. page_count: 1,
  78. storage: [],
  79. loading: false
  80. }
  81. },
  82. components: {
  83. appNoGoods
  84. },
  85. methods: {
  86. getList() {
  87. this.$showLoading();
  88. this.loading = false;
  89. this.$request({
  90. url: this.$api.pick.goods_list,
  91. method: 'get'
  92. }).then(e => {
  93. if (e.code === 0) {
  94. this.$hideLoading();
  95. let { bg_url, list, form, activity, pagination } = e.data;
  96. this.background = bg_url;
  97. this.form = form;
  98. this.activity = activity;
  99. this.list = list;
  100. this.loading = true;
  101. this.page_count = pagination.page_count;
  102. } else if (e.code === 1) {
  103. uni.showModal({
  104. title: '提示',
  105. content: e.msg,
  106. success: function() {
  107. uni.navigateBack();
  108. }
  109. });
  110. this.$hideLoading();
  111. }
  112. }).catch(() => {
  113. this.$hideLoading();
  114. });
  115. },
  116. navigator(str) {
  117. uni.navigateTo({
  118. url: str
  119. });
  120. },
  121. goRoute() {
  122. uni.navigateTo({
  123. url: `/pages/rules/index?url=${encodeURIComponent(this.$api.pick.goods_list)}&key=rule`,
  124. });
  125. },
  126. async getBottom() {
  127. const e = await this.$request({
  128. url: this.$api.pick.goods_list,
  129. method: 'get',
  130. data: {
  131. page: this.page
  132. }
  133. });
  134. if (e.code === 0) {
  135. this.list.push(...e.data.list);
  136. }
  137. },
  138. async getCart() {
  139. const e = await this.$request({
  140. url: this.$api.pick.list
  141. });
  142. if (e.code === 0) {
  143. let data = e.data.list;
  144. this.storage = 0;
  145. for (let i = 0; i < data.length;i++) {
  146. this.storage = Number(this.storage) + Number(data[i].num);
  147. }
  148. }
  149. }
  150. },
  151. onLoad() {
  152. // #ifdef MP-WEIXIN
  153. wx.showShareMenu({
  154. menus: ['shareAppMessage', 'shareTimeline']
  155. })
  156. // #endif
  157. this.getList();
  158. },
  159. onReachBottom() {
  160. if (this.page_count > this.page) {
  161. this.page++;
  162. this.getBottom();
  163. }
  164. },
  165. computed: {
  166. ...mapState({
  167. isShowSalesNum: state => state.mallConfig.mall.setting.is_show_sales_num,
  168. appImg: state => state.mallConfig.__wxapp_img.mall,
  169. appSetting: state => state.mallConfig.mall.setting,
  170. }),
  171. ...mapGetters('mallConfig', {
  172. getTheme: 'getTheme',
  173. })
  174. },
  175. // #ifdef MP-WEIXIN
  176. onShareTimeline() {
  177. // 分享朋友圈beta
  178. return this.$shareTimeline({
  179. title: this.$children[0].navigationBarTitle,
  180. query: {
  181. } // 此处填写页面的参数
  182. });
  183. },
  184. // #endif
  185. filters: {
  186. getStorage(data) {
  187. if (data > 99) {
  188. return '99+';
  189. } else {
  190. return data;
  191. }
  192. }
  193. },
  194. onShow() {
  195. this.getCart();
  196. }
  197. }
  198. </script>
  199. <style scoped lang="scss">
  200. .index {
  201. position: absolute;
  202. height: 100%;
  203. width: 100%;
  204. background-color: #ffffff;
  205. }
  206. .billing {
  207. width: #{750upx};
  208. height: #{280upx};
  209. background-size: 100% 100%;
  210. background-repeat: no-repeat;
  211. position: relative;
  212. }
  213. .rule {
  214. font-size: #{22upx};
  215. color: #ffffff;
  216. display: inline-block;
  217. position: absolute;
  218. background-color: rgba(0, 0, 0, .4);
  219. padding: #{10upx 18upx};
  220. top: #{24upx};
  221. right: #{24upx};
  222. border-radius: #{24upx};
  223. }
  224. .activity {
  225. width: #{750upx};
  226. height: #{70upx};
  227. text-align: center;
  228. line-height: #{70upx};
  229. font-size: #{26upx};
  230. }
  231. .search {
  232. height: #{88upx};
  233. width: #{750upx};
  234. background-color: #efeff4;
  235. }
  236. .input {
  237. width: #{702upx};
  238. height: #{56upx};
  239. margin-left: #{24upx};
  240. background-color: #ffffff;
  241. border-radius: #{28upx};
  242. }
  243. .pond {
  244. margin-left: #{35upx};
  245. }
  246. .pond-img {
  247. width: #{34upx};
  248. height: #{34upx};
  249. margin-right: #{8upx};
  250. }
  251. .pond-text {
  252. font-size: #{26upx};
  253. color: #ff4544;
  254. }
  255. .search-img {
  256. width: #{26upx};
  257. height: #{26upx};
  258. margin-right: #{6upx};
  259. }
  260. .search-text {
  261. color: #999999;
  262. font-size: #{26upx};
  263. margin-left: #{6upx};
  264. }
  265. .list {
  266. padding-bottom: #{150upx};
  267. }
  268. .item {
  269. padding: #{24upx};
  270. border-bottom: #{1upx} solid #eeeeee;
  271. background-color: #ffffff;
  272. position: relative;
  273. .out-dialog {
  274. width: #{220rpx};
  275. height: #{220rpx};
  276. border-radius: #{16rpx};
  277. position: absolute;
  278. top: #{24rpx};
  279. left: #{24rpx};
  280. z-index: 10;
  281. background-color: rgba(0,0,0,.5);
  282. image {
  283. width: #{220rpx};
  284. height: #{220rpx};
  285. border-radius: #{16rpx};
  286. }
  287. }
  288. }
  289. .image {
  290. width: #{220upx};
  291. height: #{220upx};
  292. border-radius: #{16upx};
  293. flex-shrink: 0;
  294. }
  295. .content {
  296. width: #{478upx};
  297. margin-left: #{24upx};
  298. height: #{228upx};
  299. }
  300. .name {
  301. font-size: #{28upx};
  302. color: #353535;
  303. }
  304. .generate {
  305. height: #{96upx};
  306. width: #{750upx};
  307. border-top: #{1upx} solid #e2e2e2;
  308. position: relative;
  309. }
  310. .generate-img {
  311. width: #{34upx};
  312. height: #{34upx};
  313. margin-right: #{7.5upx};
  314. }
  315. .generate-text {
  316. margin-left: #{7.5upx};
  317. font-size: #{32upx};
  318. }
  319. .information {
  320. margin-bottom: #{12upx};
  321. }
  322. .num {
  323. margin-bottom: #{8upx};
  324. }
  325. .sales {
  326. font-size: #{24upx};
  327. color: #999999;
  328. line-height: 1;
  329. }
  330. .value {
  331. margin-bottom: #{18upx};
  332. line-height: 1;
  333. }
  334. .price {
  335. font-size: #{32upx};
  336. line-height: 1;
  337. }
  338. .original_price {
  339. text-decoration:line-through;
  340. font-size: #{24upx};
  341. line-height: 1;
  342. color: #999999;
  343. margin-left: #{10upx};
  344. }
  345. .go-button {
  346. height: #{56upx};
  347. line-height: #{56upx};
  348. width: #{130upx};
  349. font-size: #{28upx};
  350. border-radius: #{28upx};
  351. text-align: center;
  352. color: #ffffff;
  353. }
  354. .pond-length {
  355. width: #{20upx};
  356. height: #{20upx};
  357. color: #ffffff;
  358. text-align: center;
  359. line-height: #{20upx};
  360. position: absolute;
  361. left: 40%;
  362. top: 40%;
  363. border-radius: 50%;
  364. transform: translate(40%, -50%);
  365. font-size: #{13upx};
  366. }
  367. .u-bottom-fixed {
  368. position: fixed;
  369. bottom: 0;
  370. left: 0;
  371. width: 100%;
  372. z-index: 1500;
  373. background-color: #ffffff;
  374. }
  375. </style>