index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view>
  3. <block v-if="bargain.length>0">
  4. <div class="bargain-record pad30" ref="container">
  5. <div class="item borRadius14" v-for="(item, index) in bargain" :key="index">
  6. <div class="picTxt acea-row row-between-wrapper">
  7. <div class="pictrue">
  8. <image :src="item.picUrl" />
  9. </div>
  10. <div class="text acea-row row-column-around">
  11. <div class="line1" style="width: 100%;">{{ item.activityName }}</div>
  12. <count-down :justify-left="'justify-content:left'" :bgColor="bgColor" :is-day="true" :tip-text="'倒计时 '" :day-text="'天'"
  13. :hour-text="' 时 '" :minute-text="' 分 '"
  14. :second-text="' 秒 '" :datatime="item.endTime / 1000" v-if="item.status === 1"></count-down>
  15. <div class="successTxt font-color-red" v-else-if="item.status === 2">砍价成功</div>
  16. <div class="endTxt" v-else>活动已结束</div>
  17. <div class="money">
  18. 已砍至<span class="symbol font-color-red">¥</span><span class="num font-color-red">{{ fen2yuan(item.bargainPrice) }}</span>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="bottom acea-row row-between-wrapper">
  23. <div class="purple" v-if="item.status === 1">活动进行中</div>
  24. <div class="success" v-else-if="item.status === 2">砍价成功</div>
  25. <div class="end" v-else>活动已结束</div>
  26. <div class="acea-row row-middle row-right">
  27. <div class="bnt bg-color-red" v-if="item.status === 2 && !item.orderId" @click="goConfirm(item)">
  28. 去下单
  29. </div>
  30. <div class="bnt bg-color-red" v-if="item.status === 2 && item.orderId && !item.payStatus" @click="goPay(item.orderId, item.payOrderId)">
  31. 去付款
  32. </div>
  33. <div class="bnt bg-color-red" v-if="item.status === 1" @click="goDetail(item.id, item.activityId)">
  34. 继续砍价
  35. </div>
  36. <div class="bnt bg-color-red" v-if="item.status === 3" @click="goList">
  37. 重开一个
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <Loading :loaded="status" :loading="loadingList" />
  43. </div>
  44. </block>
  45. <block v-if="bargain.length === 0">
  46. <emptyPage title="暂无砍价记录~"></emptyPage>
  47. </block>
  48. <home></home>
  49. </view>
  50. </template>
  51. <script>
  52. import CountDown from "@/components/countDown";
  53. import emptyPage from '@/components/emptyPage.vue'
  54. import { getBargainUserCancel } from "@/api/activity";
  55. import * as BargainApi from '@/api/promotion/bargain.js';
  56. import Loading from "@/components/Loading";
  57. import home from '@/components/home';
  58. import { mapGetters } from "vuex";
  59. import * as Util from '@/utils/util.js';
  60. import { toLogin } from '@/libs/login.js';
  61. export default {
  62. name: "BargainRecord",
  63. components: {
  64. CountDown,
  65. Loading,
  66. emptyPage,
  67. home,
  68. },
  69. props: {},
  70. computed: mapGetters(['isLogin', 'userInfo', 'uid']),
  71. data: function() {
  72. return {
  73. bgColor:{
  74. 'bgColor': '',
  75. 'Color': '#E93323',
  76. 'width': '40rpx',
  77. 'timeTxtwidth': '28rpx',
  78. 'isDay': false
  79. },
  80. bargain: [],
  81. status: false, // 砍价列表是否获取完成 false 未完成 true 完成
  82. loadingList: false, // 当前接口是否请求完成 false 完成 true 未完成
  83. page: 1, // 页码
  84. limit: 20, // 数量
  85. // TODO 芋艿:这里后续要干掉,应该单独有支付页
  86. payMode: [{
  87. name: "微信支付",
  88. icon: "icon-weixinzhifu",
  89. value: 'weixin',
  90. title: '微信快捷支付'
  91. },
  92. {
  93. name: "余额支付",
  94. icon: "icon-yuezhifu",
  95. value: 'yue',
  96. title: '可用余额:',
  97. number: 0
  98. }
  99. ],
  100. };
  101. },
  102. onLoad: function() {
  103. this.getBargainUserList();
  104. },
  105. onShow() {
  106. if (!this.isLogin) {
  107. toLogin();
  108. return
  109. }
  110. this.payMode[1].number = this.userInfo.nowMoney;
  111. this.$set(this, 'payMode', this.payMode);
  112. },
  113. methods: {
  114. /**
  115. * 获得拼团记录
  116. */
  117. getBargainUserList: function() {
  118. if (this.loadingList || this.status) {
  119. return;
  120. }
  121. this.loadingList = true
  122. BargainApi.getBargainRecordPage({
  123. pageNo: this.page,
  124. pageSize: this.limit
  125. }).then(res => {
  126. this.status = res.data.list.length < this.limit;
  127. this.bargain.push.apply(this.bargain, res.data.list);
  128. this.page++;
  129. this.loadingList = false;
  130. }).catch(res => {
  131. this.$dialog.error(res);
  132. this.loadingList = false;
  133. });
  134. },
  135. /**
  136. * 立即下单
  137. */
  138. goConfirm: function(item) {
  139. uni.navigateTo({
  140. url: '/pages/users/order_confirm/index?skuId=' + item.skuId + '&count=1'
  141. + '&bargainRecordId=' + item.id
  142. });
  143. },
  144. /**
  145. * 前往砍价记录的详情
  146. */
  147. goDetail: function(id, activityId) {
  148. uni.navigateTo({
  149. url: `/pages/activity/goods_bargain_details/index?id=${activityId}&startBargainUid=${this.uid}&storeBargainId=${id}`
  150. })
  151. },
  152. /**
  153. * 前往砍价活动的列表
  154. */
  155. goList: function() {
  156. uni.navigateTo({
  157. url: '/pages/activity/goods_bargain/index'
  158. })
  159. },
  160. // TODO @芋艿:貌似没看到调用的地方,估计暂时没实现
  161. getBargainUserCancel: function(bargainId) {
  162. var that = this;
  163. getBargainUserCancel({
  164. bargainId: bargainId
  165. }).then(res => {
  166. that.status = false;
  167. that.loadingList = false;
  168. that.page = 1;
  169. that.bargain = [];
  170. that.getBargainUserList();
  171. that.$util.Tips({
  172. title: res
  173. })
  174. }).catch(res => {
  175. that.$util.Tips({
  176. title: res
  177. })
  178. });
  179. },
  180. /**
  181. * 打开支付组件
  182. */
  183. goPay: function (orderId, payOrderId) {
  184. const returnUrl = encodeURIComponent('/pages/order_pay_status/index?order_id=' + orderId);
  185. uni.navigateTo({
  186. url: `/pages/goods/cashier/index?order_id=${payOrderId}&returnUrl=${returnUrl}`
  187. });
  188. },
  189. fen2yuan(price) {
  190. return Util.fen2yuan(price)
  191. }
  192. },
  193. onReachBottom() {
  194. this.getBargainUserList();
  195. }
  196. };
  197. </script>
  198. <style lang="scss" scoped>
  199. /*砍价记录*/
  200. .bargain-record .item .picTxt .text .time {
  201. height: 36rpx;
  202. line-height: 36rpx;
  203. .styleAll {
  204. color: #fc4141;
  205. font-size:24rpx;
  206. }
  207. }
  208. .bargain-record .item .picTxt .text .time .red {
  209. color: #999;
  210. font-size:24rpx;
  211. }
  212. .bargain-record .item {
  213. background-color: #fff;
  214. margin-top: 15rpx;
  215. padding: 30rpx 24rpx 0 24rpx;
  216. }
  217. .bargain-record .item .picTxt {
  218. border-bottom: 1px solid #f0f0f0;
  219. padding-bottom: 30rpx;
  220. }
  221. .bargain-record .item .picTxt .pictrue {
  222. width: 150upx;
  223. height: 150upx;
  224. }
  225. .bargain-record .item .picTxt .pictrue image {
  226. width: 100%;
  227. height: 100%;
  228. border-radius: 6upx;
  229. }
  230. .bargain-record .item .picTxt .text {
  231. width: 470rpx;
  232. font-size: 30upx;
  233. color: #333333;
  234. height: 160rpx;
  235. }
  236. .bargain-record .item .picTxt .text .time {
  237. font-size: 24upx;
  238. color: #868686;
  239. justify-content: left !important;
  240. }
  241. .bargain-record .item .picTxt .text .successTxt{
  242. font-size:24rpx;
  243. }
  244. .bargain-record .item .picTxt .text .endTxt{
  245. font-size:24rpx;
  246. color: #999;
  247. }
  248. .bargain-record .item .picTxt .text .money {
  249. font-size: 24upx;
  250. color: #999999;
  251. }
  252. .bargain-record .item .picTxt .text .money .num {
  253. font-size: 32upx;
  254. font-weight: bold;
  255. }
  256. .bargain-record .item .picTxt .text .money .symbol {
  257. font-weight: bold;
  258. }
  259. .bargain-record .item .bottom {
  260. height: 100upx;
  261. font-size: 27upx;
  262. }
  263. .bargain-record .item .bottom .purple {
  264. color: #f78513;
  265. }
  266. .bargain-record .item .bottom .end {
  267. color: #999;
  268. }
  269. .bargain-record .item .bottom .success {
  270. color: $theme-color;
  271. }
  272. .bargain-record .item .bottom .bnt {
  273. font-size: 27upx;
  274. color: #fff;
  275. width: 176upx;
  276. height: 60upx;
  277. border-radius: 32upx;
  278. text-align: center;
  279. line-height: 60upx;
  280. }
  281. .bargain-record .item .bottom .bnt.cancel {
  282. color: #aaa;
  283. border: 1px solid #ddd;
  284. }
  285. .bargain-record .item .bottom .bnt~.bnt {
  286. margin-left: 18upx;
  287. }
  288. </style>