You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

352 lines
9.3 KiB

3 months ago
  1. <template>
  2. <view :data-theme="theme">
  3. <block v-if="bargain.length>0">
  4. <div class="bargain-record" 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" v-else-if="item.status === 3 && item.isDel === false">砍价成功</div>
  16. <div class="successTxt " v-else-if="item.status === 3 && item.isDel === true && item.isPay === false">砍价失败</div>
  17. <div class="endTxt" v-else>活动已结束</div>
  18. <div class="money">
  19. 已砍至<span class="symbol font_color"></span><span class="num font_color">{{ item.surplusPrice }}</span>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="bottom acea-row row-between-wrapper">
  24. <div class="purple" v-if="item.status === 1">活动进行中</div>
  25. <div class="success" v-else-if="item.status === 3 && item.isDel === false">砍价成功</div>
  26. <div class="end" v-else-if="item.status === 3 && item.isDel === true && item.isPay === false">砍价失败</div>
  27. <div class="end" v-else>活动已结束</div>
  28. <div class="acea-row row-middle row-right">
  29. <div class="bnt bg_color" v-if="item.status === 3 && !item.isOrder" @click="goConfirm(item)">
  30. 去付款
  31. </div>
  32. <div class="bnt bg_color" v-if="item.status === 3 && !item.isDel && item.isOrder && !item.isPay" @click="goPay(item.surplusPrice,item.orderNo)">
  33. 立即付款
  34. </div>
  35. <div class="bnt bg_color" v-if="item.status === 1" @click="goDetail(item.id)">
  36. 继续砍价
  37. </div>
  38. <div class="bnt bg_color" v-if="item.status === 2" @click="goList">重开一个</div>
  39. </div>
  40. </div>
  41. </div>
  42. <Loading :loaded="status" :loading="loadingList"></Loading>
  43. </div>
  44. </block>
  45. <block v-if="bargain.length == 0">
  46. <emptyPage title="暂无砍价记录~"></emptyPage>
  47. </block>
  48. <payment :pay_close="pay_close" @onChangeFun='onChangeFun' :order_id="pay_order_id" :totalPrice='totalPrice'></payment>
  49. </view>
  50. </template>
  51. <script>
  52. import CountDown from "@/components/countDown";
  53. import emptyPage from '@/components/emptyPage.vue'
  54. import {
  55. getBargainUserList,
  56. getBargainUserCancel
  57. } from "@/api/activity";
  58. import Loading from "@/components/Loading";
  59. import payment from '@/components/payment';
  60. import {mapGetters} from "vuex";
  61. import {setThemeColor} from '@/utils/setTheme.js'
  62. import animationType from '@/utils/animationType.js'
  63. let app = getApp();
  64. export default {
  65. name: "BargainRecord",
  66. components: {
  67. CountDown,
  68. Loading,
  69. emptyPage,
  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. theme:app.globalData.theme
  106. };
  107. },
  108. onShow() {
  109. if (this.isLogin) {
  110. this.payMode[1].number = this.userInfo.nowMoney;
  111. this.$set(this, 'payMode', this.payMode);
  112. this.getBargainUserList();
  113. this.bgColor.Color = setThemeColor();
  114. } else {
  115. toLogin();
  116. }
  117. },
  118. methods: {
  119. /**
  120. * 打开支付组件
  121. *
  122. */
  123. goPay(pay_price, order_id) {
  124. this.$set(this, 'pay_close', true);
  125. this.$set(this, 'pay_order_id', order_id);
  126. this.$set(this, 'totalPrice', pay_price);
  127. },
  128. /**
  129. * 事件回调
  130. *
  131. */
  132. onChangeFun: function(e) {
  133. let opt = e;
  134. let action = opt.action || null;
  135. let value = opt.value != undefined ? opt.value : null;
  136. (action && this[action]) && this[action](value);
  137. },
  138. /**
  139. * 关闭支付组件
  140. *
  141. */
  142. payClose: function() {
  143. this.pay_close = false;
  144. },
  145. /**
  146. * 支付成功回调
  147. *
  148. */
  149. pay_complete: function() {
  150. this.status = false;
  151. this.page = 1;
  152. this.$set(this, 'bargain', []);
  153. this.$set(this, 'pay_close', false);
  154. this.getBargainUserList();
  155. },
  156. /**
  157. * 支付失败回调
  158. *
  159. */
  160. pay_fail: function() {
  161. this.pay_close = false;
  162. },
  163. goConfirm: function(item) { //立即支付
  164. if (this.isLogin === false) {
  165. toLogin();
  166. } else {
  167. uni.navigateTo({
  168. animationType: animationType.type, animationDuration: animationType.duration,
  169. url: `/pages/activity/goods_bargain_details/index?id=${item.id}&startBargainUid=${this.uid}&storeBargainId=${item.bargainUserId}`
  170. })
  171. }
  172. },
  173. goDetail: function(id) {
  174. uni.navigateTo({
  175. animationType: animationType.type, animationDuration: animationType.duration,
  176. url: `/pages/activity/goods_bargain_details/index?id=${id}&startBargainUid=${this.uid}`
  177. })
  178. },
  179. // 砍价列表
  180. goList: function() {
  181. uni.navigateTo({
  182. animationType: animationType.type, animationDuration: animationType.duration,
  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">
  232. page {
  233. @include main_bg_color(theme);
  234. height: 100vh;
  235. overflow: auto;
  236. }
  237. </style>
  238. <style lang="scss" scoped>
  239. /*砍价记录*/
  240. .bargain-record{
  241. padding: 0 30rpx 15rpx;
  242. }
  243. .bargain-record .item .picTxt .text .time {
  244. height: 36rpx;
  245. line-height: 36rpx;
  246. .styleAll {
  247. color: #fc4141;
  248. font-size:24rpx;
  249. }
  250. }
  251. .bargain-record .item .picTxt .text .time .red {
  252. color: #999;
  253. font-size:24rpx;
  254. }
  255. .bargain-record .item {
  256. background-color: #fff;
  257. margin-top: 15rpx;
  258. padding: 30rpx 24rpx 0 24rpx;
  259. }
  260. .bargain-record .item .picTxt {
  261. border-bottom: 1px solid #f0f0f0;
  262. padding-bottom: 30rpx;
  263. }
  264. .bargain-record .item .picTxt .pictrue {
  265. width: 150upx;
  266. height: 150upx;
  267. }
  268. .bargain-record .item .picTxt .pictrue image {
  269. width: 100%;
  270. height: 100%;
  271. border-radius: 6upx;
  272. }
  273. .bargain-record .item .picTxt .text {
  274. width: 470rpx;
  275. font-size: 30upx;
  276. color: #333333;
  277. height: 160rpx;
  278. }
  279. .bargain-record .item .picTxt .text .time {
  280. font-size: 24upx;
  281. color: #868686;
  282. justify-content: left !important;
  283. }
  284. .bargain-record .item .picTxt .text .successTxt{
  285. font-size:24rpx;
  286. }
  287. .bargain-record .item .picTxt .text .endTxt{
  288. font-size:24rpx;
  289. color: #999;
  290. }
  291. .bargain-record .item .picTxt .text .money {
  292. font-size: 24upx;
  293. color: #999999;
  294. }
  295. .bargain-record .item .picTxt .text .money .num {
  296. font-size: 32upx;
  297. font-weight: bold;
  298. }
  299. .bargain-record .item .picTxt .text .money .symbol {
  300. font-weight: bold;
  301. }
  302. .bargain-record .item .bottom {
  303. height: 100upx;
  304. font-size: 27upx;
  305. }
  306. .bargain-record .item .bottom .purple {
  307. color: #f78513;
  308. }
  309. .bargain-record .item .bottom .end {
  310. color: #999;
  311. }
  312. .bargain-record .item .bottom .success {
  313. color: $theme-color;
  314. }
  315. .bargain-record .item .bottom .bnt {
  316. font-size: 27upx;
  317. color: #fff;
  318. width: 176upx;
  319. height: 60upx;
  320. border-radius: 32upx;
  321. text-align: center;
  322. line-height: 60upx;
  323. }
  324. .bg_color{
  325. @include main_bg_color(theme);
  326. }
  327. .font_color{
  328. @include price_color(theme);
  329. }
  330. .bargain-record .item .bottom .bnt.cancel {
  331. color: #aaa;
  332. border: 1px solid #ddd;
  333. }
  334. .bargain-record .item .bottom .bnt~.bnt {
  335. margin-left: 18upx;
  336. }
  337. </style>