index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <view :style="colorStyle" style="background-color: var(--view-theme); min-height: 100vh; padding-bottom: 1rpx">
  3. <view class="bargain-list">
  4. <!-- #ifndef APP-PLUS -->
  5. <!-- <view class='iconfont icon-xiangzuo' @tap='goBack' :style="'top:'+ (navH/2 - 12) +'rpx'" v-if="returnShow">
  6. </view> -->
  7. <!-- #endif -->
  8. <view class="header" :style="'background-image: url(' + hostUrl + picUrl.bgList + ');'"></view>
  9. <view class="list">
  10. <block v-for="(item, index) in bargainList" :key="index">
  11. <view class="item acea-row row-between-wrapper" @tap="openSubscribe(item)">
  12. <view class="pictrue">
  13. <image :src="item.image"></image>
  14. </view>
  15. <view class="text acea-row row-column-around">
  16. <view class="name line1">{{ item.title || '' }}</view>
  17. <view class="num">
  18. <text class="iconfont icon-pintuan"></text>
  19. {{ item.people }}{{ $t(`人正在参与`) }}
  20. </view>
  21. <view class="money">
  22. {{ $t(`最低`) }} : {{ $t(`¥`) }}
  23. <text class="price">{{ item.min_price }}</text>
  24. </view>
  25. </view>
  26. <view class="cutBnt">
  27. <text class="iconfont icon-kanjia"></text>
  28. {{ $t(`参与砍价`) }}
  29. </view>
  30. </view>
  31. </block>
  32. </view>
  33. </view>
  34. <!-- #ifdef MP -->
  35. <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  36. <!-- #endif -->
  37. <!-- #ifndef MP -->
  38. <home></home>
  39. <!-- #endif -->
  40. </view>
  41. </template>
  42. <script>
  43. let app = getApp();
  44. import { getBargainList } from '@/api/activity.js';
  45. import { openBargainSubscribe } from '@/utils/SubscribeMessage.js';
  46. import { getUserInfo } from '@/api/user.js';
  47. import home from '@/components/home';
  48. import { toLogin } from '@/libs/login.js';
  49. import { colorChange } from '@/api/api.js';
  50. import { mapGetters } from 'vuex';
  51. // #ifdef MP
  52. import authorize from '@/components/Authorize';
  53. // #endif
  54. import colors from '@/mixins/color';
  55. import { HTTP_REQUEST_URL } from '@/config/app.js';
  56. export default {
  57. mixins: [colors],
  58. components: {
  59. home,
  60. // #ifdef MP
  61. authorize
  62. // #endif
  63. },
  64. data() {
  65. return {
  66. hostUrl: HTTP_REQUEST_URL,
  67. bargainList: [],
  68. page: 1,
  69. limit: 20,
  70. loading: false,
  71. loadend: false,
  72. userInfo: {},
  73. navH: '',
  74. isAuto: false, //没有授权的不会自动授权
  75. isShowAuth: false, //是否隐藏授权
  76. returnShow: true,
  77. picUrl: {},
  78. picList: [
  79. {
  80. bgList: '/statics/system_images/bargain_bg_0.jpeg'
  81. },
  82. {
  83. bgList: '/statics/system_images/bargain_bg_1.jpeg'
  84. },
  85. {
  86. bgList: '/statics/system_images/bargain_bg_2.jpeg'
  87. },
  88. {
  89. bgList: '/statics/system_images/bargain_bg_3.jpeg'
  90. },
  91. {
  92. bgList: '/statics/system_images/bargain_bg_4.jpeg'
  93. }
  94. ]
  95. };
  96. },
  97. computed: mapGetters(['isLogin']),
  98. watch: {
  99. isLogin: {
  100. handler: function (newV, oldV) {
  101. if (newV) {
  102. this.getUserInfo();
  103. this.getBargainList();
  104. }
  105. },
  106. deep: true
  107. },
  108. colorStatus(newValue, oldValue) {
  109. if (newValue) {
  110. this.colorShow(newValue);
  111. }
  112. }
  113. },
  114. onLoad(options) {
  115. if (!this.colorStatus) {
  116. colorChange('color_change').then((res) => {
  117. this.colorShow(res.data.status);
  118. });
  119. }
  120. var pages = getCurrentPages();
  121. this.returnShow = pages.length === 1 ? false : true;
  122. uni.setNavigationBarTitle({
  123. title: this.$t(`砍价列表`)
  124. });
  125. // #ifdef MP
  126. this.navH = app.globalData.navH * 2.5;
  127. // #endif
  128. // #ifdef H5
  129. this.navH = app.globalData.navHeight;
  130. // #endif
  131. this.getBargainList();
  132. if (this.isLogin) {
  133. this.getUserInfo();
  134. }
  135. },
  136. methods: {
  137. colorShow(colorStatus) {
  138. switch (colorStatus) {
  139. case 1:
  140. this.picUrl = this.picList[0];
  141. break;
  142. case 2:
  143. this.picUrl = this.picList[1];
  144. break;
  145. case 3:
  146. this.picUrl = this.picList[2];
  147. break;
  148. case 4:
  149. this.picUrl = this.picList[3];
  150. break;
  151. case 5:
  152. this.picUrl = this.picList[4];
  153. break;
  154. default:
  155. this.picUrl = this.picList[2];
  156. break;
  157. }
  158. },
  159. // 授权关闭
  160. authColse: function (e) {
  161. this.isShowAuth = e;
  162. },
  163. /*
  164. * 获取用户信息
  165. */
  166. getUserInfo: function () {
  167. let that = this;
  168. getUserInfo().then((res) => {
  169. that.$set(that, 'userInfo', res.data);
  170. });
  171. },
  172. goBack: function () {
  173. uni.navigateBack({
  174. delta: 1
  175. });
  176. },
  177. onLoadFun: function (e) {
  178. this.getBargainList();
  179. this.userInfo = e;
  180. },
  181. openSubscribe: function (item) {
  182. if (!this.isLogin) {
  183. toLogin();
  184. }
  185. let page = '/pages/activity/goods_bargain_details/index?id=' + item.id + '&bargain=' + this.userInfo.uid;
  186. // #ifndef MP
  187. uni.navigateTo({
  188. url: page
  189. });
  190. // #endif
  191. // #ifdef MP
  192. uni.showLoading({
  193. title: this.$t(`正在加载中`)
  194. });
  195. openBargainSubscribe()
  196. .then((res) => {
  197. uni.hideLoading();
  198. uni.navigateTo({
  199. url: page
  200. });
  201. })
  202. .catch((err) => {
  203. uni.hideLoading();
  204. });
  205. // #endif
  206. },
  207. getBargainList: function () {
  208. let that = this;
  209. if (that.loadend) return;
  210. if (that.loading) return;
  211. that.loading = true;
  212. getBargainList({
  213. page: that.page,
  214. limit: that.limit
  215. })
  216. .then(function (res) {
  217. that.$set(that, 'bargainList', that.bargainList.concat(res.data));
  218. that.$set(that, 'page', that.page + 1);
  219. that.$set(that, 'loadend', that.limit > res.data.length);
  220. that.$set(that, 'loading', false);
  221. })
  222. .catch((res) => {
  223. that.loading = false;
  224. });
  225. }
  226. },
  227. onReachBottom: function () {
  228. this.getBargainList();
  229. }
  230. };
  231. </script>
  232. <style lang="scss">
  233. // page {
  234. // background-color: #e93323 !important;
  235. // }
  236. .bargain-list .icon-xiangzuo {
  237. font-size: 40rpx;
  238. color: #fff;
  239. position: fixed;
  240. left: 30rpx;
  241. z-index: 99;
  242. transform: translateY(-20%);
  243. }
  244. .bargain-list .header {
  245. background-repeat: no-repeat;
  246. background-size: 100% 100%;
  247. width: 750rpx;
  248. height: 713rpx;
  249. }
  250. .bargain-list .list {
  251. background-color: #fff;
  252. border: 6rpx solid #fc8b42;
  253. border-radius: 30rpx;
  254. margin: -140rpx 30rpx 66rpx 30rpx;
  255. padding: 0 24rpx;
  256. }
  257. .bargain-list .list .item {
  258. border-bottom: 1rpx solid #eee;
  259. position: relative;
  260. height: 223rpx;
  261. }
  262. .bargain-list .list .item .pictrue {
  263. width: 160rpx;
  264. height: 160rpx;
  265. }
  266. .bargain-list .list .item .pictrue image {
  267. width: 100%;
  268. height: 100%;
  269. border-radius: 6rpx;
  270. }
  271. .bargain-list .list .item .text {
  272. width: 450rpx;
  273. font-size: 30rpx;
  274. color: #282828;
  275. height: 160rpx;
  276. }
  277. .bargain-list .list .item .text .name {
  278. width: 100%;
  279. }
  280. .bargain-list .list .item .text .num {
  281. font-size: 26rpx;
  282. color: #999;
  283. }
  284. .bargain-list .list .item .text .num .iconfont {
  285. font-size: 35rpx;
  286. margin-right: 7rpx;
  287. }
  288. .bargain-list .list .item .text .money {
  289. font-size: 24rpx;
  290. font-weight: bold;
  291. color: var(--view-theme);
  292. }
  293. .bargain-list .list .item .text .money .price {
  294. font-size: 32rpx;
  295. }
  296. .bargain-list .list .item .cutBnt {
  297. position: absolute;
  298. width: 180rpx;
  299. height: 50rpx;
  300. border-radius: 50rpx;
  301. font-size: 24rpx;
  302. color: #fff;
  303. text-align: center;
  304. line-height: 46rpx;
  305. right: 24rpx;
  306. bottom: 28rpx;
  307. box-shadow: 0 7rpx 0 var(--view-minorColor);
  308. background-color: var(--view-theme);
  309. }
  310. .bargain-list .list .item .cutBnt .iconfont {
  311. margin-right: 8rpx;
  312. font-size: 30rpx;
  313. }
  314. .bargain-list .list .load {
  315. font-size: 24rpx;
  316. height: 85rpx;
  317. text-align: center;
  318. line-height: 85rpx;
  319. }
  320. </style>