index.vue 12 KB

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