index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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.image" />
  9. </div>
  10. <div class="text acea-row row-column-around">
  11. <div class="line1" style="width: 100%;">{{ item.title }}</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.stopTime/1000" v-if="item.status === 1"></count-down>
  15. <div class="successTxt font-color-red" v-else-if="item.status === 3">砍价成功</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">{{ item.surplusPrice }}</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 === 3">砍价成功</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 === 3 && !item.isOrder" @click="goConfirm(item)">
  28. 去付款
  29. </div>
  30. <div class="bnt bg-color-red" v-if="item.status === 3 && !item.isDel && item.isOrder && !item.isPay" @click="goPay(item.surplusPrice,item.orderNo)">
  31. 立即付款
  32. </div>
  33. <div class="bnt bg-color-red" v-if="item.status === 1" @click="goDetail(item.id)">
  34. 继续砍价
  35. </div>
  36. <div class="bnt bg-color-red" v-if="item.status === 2" @click="goList">重开一个</div>
  37. </div>
  38. </div>
  39. </div>
  40. <Loading :loaded="status" :loading="loadingList"></Loading>
  41. </div>
  42. </block>
  43. <block v-if="bargain.length == 0">
  44. <emptyPage title="暂无砍价记录~"></emptyPage>
  45. </block>
  46. <home></home>
  47. <payment :payMode='payMode' :pay_close="pay_close" @onChangeFun='onChangeFun' :order_id="pay_order_id" :totalPrice='totalPrice'></payment>
  48. </view>
  49. </template>
  50. <script>
  51. import CountDown from "@/components/countDown";
  52. import emptyPage from '@/components/emptyPage.vue'
  53. import {
  54. getBargainUserList,
  55. getBargainUserCancel
  56. } from "@/api/activity";
  57. import Loading from "@/components/Loading";
  58. import home from '@/components/home';
  59. import payment from '@/components/payment';
  60. import {
  61. mapGetters
  62. } from "vuex";
  63. export default {
  64. name: "BargainRecord",
  65. components: {
  66. CountDown,
  67. Loading,
  68. emptyPage,
  69. home,
  70. payment
  71. },
  72. props: {},
  73. computed: mapGetters(['isLogin', 'userInfo', 'uid']),
  74. data: function() {
  75. return {
  76. bgColor:{
  77. 'bgColor': '',
  78. 'Color': '#E93323',
  79. 'width': '40rpx',
  80. 'timeTxtwidth': '28rpx',
  81. 'isDay': false
  82. },
  83. bargain: [],
  84. status: false, //砍价列表是否获取完成 false 未完成 true 完成
  85. loadingList: false, //当前接口是否请求完成 false 完成 true 未完成
  86. page: 1, //页码
  87. limit: 20, //数量
  88. payMode: [{
  89. name: "微信支付",
  90. icon: "icon-weixinzhifu",
  91. value: 'weixin',
  92. title: '微信快捷支付'
  93. },
  94. {
  95. name: "余额支付",
  96. icon: "icon-yuezhifu",
  97. value: 'yue',
  98. title: '可用余额:',
  99. number: 0
  100. }
  101. ],
  102. pay_close: false,
  103. pay_order_id: '',
  104. totalPrice: '0'
  105. };
  106. },
  107. onLoad: function() {
  108. this.getBargainUserList();
  109. // this.$scroll(this.$refs.container, () => {
  110. // !this.loadingList && this.getBargainUserList();
  111. // });
  112. },
  113. onShow() {
  114. if (this.isLogin) {
  115. this.payMode[1].number = this.userInfo.nowMoney;
  116. this.$set(this, 'payMode', this.payMode);
  117. } else {
  118. toLogin();
  119. }
  120. },
  121. methods: {
  122. /**
  123. * 打开支付组件
  124. *
  125. */
  126. goPay(pay_price, order_id) {
  127. this.$set(this, 'pay_close', true);
  128. this.$set(this, 'pay_order_id', order_id);
  129. this.$set(this, 'totalPrice', pay_price);
  130. },
  131. /**
  132. * 事件回调
  133. *
  134. */
  135. onChangeFun: function(e) {
  136. let opt = e;
  137. let action = opt.action || null;
  138. let value = opt.value != undefined ? opt.value : null;
  139. (action && this[action]) && this[action](value);
  140. },
  141. /**
  142. * 关闭支付组件
  143. *
  144. */
  145. payClose: function() {
  146. this.pay_close = false;
  147. },
  148. /**
  149. * 支付成功回调
  150. *
  151. */
  152. pay_complete: function() {
  153. this.status = false;
  154. this.page = 1;
  155. this.$set(this, 'bargain', []);
  156. this.$set(this, 'pay_close', false);
  157. this.getBargainUserList();
  158. },
  159. /**
  160. * 支付失败回调
  161. *
  162. */
  163. pay_fail: function() {
  164. this.pay_close = false;
  165. },
  166. goConfirm: function(item) { //立即支付
  167. if (this.isLogin === false) {
  168. toLogin();
  169. } else {
  170. uni.navigateTo({
  171. url: `/pages/activity/goods_bargain_details/index?id=${item.id}&startBargainUid=${this.uid}&storeBargainId=${item.bargainUserId}`
  172. })
  173. }
  174. },
  175. goDetail: function(id) {
  176. uni.navigateTo({
  177. url: `/pages/activity/goods_bargain_details/index?id=${id}&startBargainUid=${this.uid}`
  178. })
  179. },
  180. // 砍价列表
  181. goList: function() {
  182. uni.navigateTo({
  183. url: '/pages/activity/goods_bargain/index'
  184. })
  185. },
  186. getBargainUserList: function() {
  187. var that = this;
  188. if (that.loadingList) return;
  189. if (that.status) return;
  190. getBargainUserList({
  191. page: that.page,
  192. limit: that.limit
  193. })
  194. .then(res => {
  195. that.status = res.data.list.length < that.limit;
  196. that.bargain.push.apply(that.bargain, res.data.list);
  197. that.page++;
  198. that.loadingList = false;
  199. })
  200. .catch(res => {
  201. that.$dialog.error(res);
  202. });
  203. },
  204. getBargainUserCancel: function(bargainId) {
  205. var that = this;
  206. getBargainUserCancel({
  207. bargainId: bargainId
  208. })
  209. .then(res => {
  210. that.status = false;
  211. that.loadingList = false;
  212. that.page = 1;
  213. that.bargain = [];
  214. that.getBargainUserList();
  215. that.$util.Tips({
  216. title: res
  217. })
  218. })
  219. .catch(res => {
  220. that.$util.Tips({
  221. title: res
  222. })
  223. });
  224. }
  225. },
  226. onReachBottom() {
  227. this.getBargainUserList();
  228. }
  229. };
  230. </script>
  231. <style lang="scss" scoped>
  232. /*砍价记录*/
  233. .bargain-record .item .picTxt .text .time {
  234. height: 36rpx;
  235. line-height: 36rpx;
  236. .styleAll {
  237. color: #fc4141;
  238. font-size:24rpx;
  239. }
  240. }
  241. .bargain-record .item .picTxt .text .time .red {
  242. color: #999;
  243. font-size:24rpx;
  244. }
  245. .bargain-record .item {
  246. background-color: #fff;
  247. margin-top: 15rpx;
  248. padding: 30rpx 24rpx 0 24rpx;
  249. }
  250. .bargain-record .item .picTxt {
  251. border-bottom: 1px solid #f0f0f0;
  252. padding-bottom: 30rpx;
  253. }
  254. .bargain-record .item .picTxt .pictrue {
  255. width: 150upx;
  256. height: 150upx;
  257. }
  258. .bargain-record .item .picTxt .pictrue image {
  259. width: 100%;
  260. height: 100%;
  261. border-radius: 6upx;
  262. }
  263. .bargain-record .item .picTxt .text {
  264. width: 470rpx;
  265. font-size: 30upx;
  266. color: #333333;
  267. height: 160rpx;
  268. }
  269. .bargain-record .item .picTxt .text .time {
  270. font-size: 24upx;
  271. color: #868686;
  272. justify-content: left !important;
  273. }
  274. .bargain-record .item .picTxt .text .successTxt{
  275. font-size:24rpx;
  276. }
  277. .bargain-record .item .picTxt .text .endTxt{
  278. font-size:24rpx;
  279. color: #999;
  280. }
  281. .bargain-record .item .picTxt .text .money {
  282. font-size: 24upx;
  283. color: #999999;
  284. }
  285. .bargain-record .item .picTxt .text .money .num {
  286. font-size: 32upx;
  287. font-weight: bold;
  288. }
  289. .bargain-record .item .picTxt .text .money .symbol {
  290. font-weight: bold;
  291. }
  292. .bargain-record .item .bottom {
  293. height: 100upx;
  294. font-size: 27upx;
  295. }
  296. .bargain-record .item .bottom .purple {
  297. color: #f78513;
  298. }
  299. .bargain-record .item .bottom .end {
  300. color: #999;
  301. }
  302. .bargain-record .item .bottom .success {
  303. color: $theme-color;
  304. }
  305. .bargain-record .item .bottom .bnt {
  306. font-size: 27upx;
  307. color: #fff;
  308. width: 176upx;
  309. height: 60upx;
  310. border-radius: 32upx;
  311. text-align: center;
  312. line-height: 60upx;
  313. }
  314. .bargain-record .item .bottom .bnt.cancel {
  315. color: #aaa;
  316. border: 1px solid #ddd;
  317. }
  318. .bargain-record .item .bottom .bnt~.bnt {
  319. margin-left: 18upx;
  320. }
  321. </style>