Bargainshare.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="false"><view class="div whole-wrapper">
  3. <title-header />
  4. <view class="div bargain-share" :style="'background-image:url('+bargainbg+')'" :class="flag?'':'inactive'" v-if="bargainorder_info">
  5. <view class="div bargain-info" @click="goGoods">
  6. <view class="div member_avatar"><image mode="aspectFit" class="img" :src="bargainorder_info.bargainorder_initiator_avatar"/></view>
  7. <view class="div member_name">{{bargainorder_info.bargainorder_initiator_name}}</view>
  8. <view class="div bargain_remark" v-if="bargainorder_info.bargain_remark">[{{bargainorder_info.bargain_remark}}]</view>
  9. <view class="div goods_info">
  10. <view class="div p_img"><image mode="aspectFit" class="img" :src="bargainorder_info.bargain_goods_image_url"/></view>
  11. <view class="div p_info">
  12. <view class="div goods_name">{{bargainorder_info.bargain_goods_name}}</view>
  13. <view class="div bargain_goods_price">¥<text class="em">{{bargainorder_info.bargainorder_current_price}}</text><del>{{bargainorder_info.bargain_goods_price}}</del></view>
  14. </view>
  15. </view>
  16. <view v-if="!flag" class="div expired">砍价已过期</view>
  17. </view>
  18. <view class="div bargain-order" v-if="flag">
  19. <view class="div connect-wrapper">
  20. <view class="div top-dot dot"></view>
  21. <view class="div bottom-dot dot"></view>
  22. <view class="div round"></view>
  23. </view>
  24. <view class="div connect-wrapper right">
  25. <view class="div top-dot dot"></view>
  26. <view class="div bottom-dot dot"></view>
  27. <view class="div round"></view>
  28. </view>
  29. <view class="div count">已砍{{bargainorder_info.bargain_goods_diff_price}}元</view>
  30. <view class="div progress-wrapper mt-10">
  31. <view class="div progress-back"><view class="div progress-front" :style="'width:'+bargainorder_info.bargain_percent+'%'"><view class="div arrow"></view></view></view>
  32. </view>
  33. <view class="div count-down-wrapper mt-10">
  34. 砍价还剩<text class="span block">{{hours}}</text>:<text class="span block">{{minute}}</text>:<text class="span block">{{second}}</text>结束
  35. </view>
  36. <view class="div button-1 mt-10 mb-5" :class="(bargainorder_info.bargain_if_add && (bargainorder_info.bargain_total>bargainorder_info.bargainorder_times)) || (user && user.member_id==bargainorder_info.bargainorder_initiator_id)?'active':''" @click="addLog"><image mode="aspectFit" class="img gloss" src="../../../static/image/home/home-bargain-gloss.png" />{{bargainorder_info.bargain_if_add?(user && user.member_id==bargainorder_info.bargainorder_initiator_id?(bargainorder_info.bargain_total<=bargainorder_info.bargainorder_times?'砍价完成去下单':'邀请好友帮砍'):(bargainorder_info.bargain_total<=bargainorder_info.bargainorder_times?'砍价已完成':'帮好友砍一刀')):'您已经砍过价了'}}</view>
  37. <view class="div notice">加油!成败在此一举</view>
  38. </view>
  39. <view class="div bargain-log">
  40. <view class="div title mt-5">| 砍价记录 |</view>
  41. <view class="div scroll-wrapper" v-if="bargainlog_list && bargainlog_list.length">
  42. <view class="ul" :class="'line-'+bargainlog_list.length">
  43. <view class="li" v-for="(item,index) in bargainlog_list" :key="index">
  44. <view class="div p_img"><image mode="aspectFit" class="img" :src="item.pbargainlog_member_avatar"/></view>
  45. <view class="div p_name">{{item.pbargainlog_member_name}}</view>
  46. <view class="div p_price">帮砍<text class="em">¥{{item.pbargainlog_price}}</text></view>
  47. </view>
  48. <slot v-if="bargainlog_list.length>3">
  49. <view class="li" v-for="i in 3" :key="i">
  50. <view class="div p_img"><image mode="aspectFit" class="img" :src="bargainlog_list[i].pbargainlog_member_avatar"/></view>
  51. <view class="div p_name">{{bargainlog_list[i].pbargainlog_member_name}}</view>
  52. <view class="div p_price">帮砍<text class="em">¥{{bargainlog_list[i].pbargainlog_price}}</text></view>
  53. </view>
  54. </slot>
  55. </view>
  56. </view>
  57. <view v-else class="div null">暂无砍价记录</view>
  58. </view>
  59. </view>
  60. <uni-popup background-color="#fff" ref="posterVisible">
  61. <image mode="aspectFit" class="poster-img" :src="posterUrl">
  62. </uni-popup>
  63. </view>
  64. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  65. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  66. </uni-popup>
  67. </home-base>
  68. </template>
  69. <script>
  70. import {getFontSize} from '@/util/common'
  71. import TitleHeader from '../../TitleHeader'
  72. import { urlencode } from '@/util/common'
  73. import HomeBase from '../HomeBase'
  74. import { getBargainInfo, getBargainOrderInfo, getBargainLogList } from '../../../api/homeBargain'
  75. import { addBargainLog } from '../../../api/memberBargain'
  76. import { mapState } from 'vuex'
  77. import { env } from '../../../static/config'
  78. export default {
  79. name: 'Share',
  80. data(){
  81. return {
  82. dialog:{},
  83. flag: false,
  84. posterUrl: '',
  85. hours: '',
  86. minute: '',
  87. second: '',
  88. time: false,
  89. isshow: true,
  90. bargainorder_id: 0,
  91. bargainorder_info: false,
  92. bargainlog_list: false,
  93. bargainbg: env.SITE_URL+'/uploads/home/h5/home/home-bargain-bg.jpg'
  94. }
  95. },
  96. components:{
  97. TitleHeader,
  98. HomeBase,
  99. },
  100. onLoad: function (option) {
  101. this.bargainorder_id=option.bargainorder_id
  102. if (!this.bargainorder_id) {
  103. uni.showToast({icon:'none',title: '缺少参数'})
  104. } else {
  105. this.posterUrl = env.API_HOST + '/index/getQrcode?url=' + encodeURIComponent(env.H5_HOST + 'pages/home/bargain/Bargainshare?bargainorder_id=' + this.bargainorder_id)
  106. this.getBargainOrderInfo()
  107. }
  108. },
  109. computed: {
  110. fontSize(){
  111. return getFontSize()
  112. },
  113. ...mapState({
  114. user: state => state.member.info,
  115. token: state => state.member.token
  116. })
  117. },
  118. mounted () {
  119. this.time = setInterval(() => {
  120. if (this.flag == false) {
  121. clearInterval(this.time)
  122. } else {
  123. this.timeDown()
  124. }
  125. }, 1000)
  126. },
  127. methods:{
  128. closeDialog(){
  129. },
  130. confirmDialog(value){
  131. value = parseInt(value)
  132. if (value < 1 || value > this.dialog.data.bargain_info.bargain_limit) {
  133. uni.showToast({icon:'none',title: '数量填写错误'})
  134. return
  135. }
  136. let params = { buy_now: 1, cart_id: this.bargainorder_info.bargain_goods_id + '|' + value, bargainorder_id: this.bargainorder_id }
  137. uni.navigateTo({ url: '/pages/member/buy/step1'+'?'+urlencode( params )})
  138. },
  139. showPopup(id){
  140. this.$refs[id].open()
  141. },
  142. hidePopup(id){
  143. this.$refs[id].close()
  144. },
  145. goGoods () {
  146. uni.navigateTo({ url: '/pages/home/goodsdetail/Goodsdetail'+'?'+urlencode( { goods_id: this.bargainorder_info.bargain_goods_id, bargain_id: this.bargainorder_info.bargain_id } )})
  147. },
  148. getBargainOrderInfo () {
  149. getBargainOrderInfo(this.bargainorder_id, this.token).then(res => {
  150. this.bargainorder_info = res.result.bargainorder_info
  151. let nowTime = new Date()
  152. if (this.bargainorder_info.bargainorder_endtime > nowTime.getTime() / 1000) {
  153. this.flag = true
  154. }
  155. getBargainLogList(this.bargainorder_id, { per_page: 10 }).then(res => {
  156. this.bargainlog_list = res.result.bargainlog_list
  157. }).catch(function (error) {
  158. uni.showToast({icon:'none',title: error.message})
  159. })
  160. }).catch(function (error) {
  161. uni.showToast({icon:'none',title: error.message})
  162. })
  163. },
  164. addLog () {
  165. if (!this.flag || !this.bargainorder_info.bargain_if_add) {
  166. return
  167. }
  168. if (this.bargainorder_info.bargain_total <= this.bargainorder_info.bargainorder_times) {
  169. if (this.user && this.user.member_id == this.bargainorder_info.bargainorder_initiator_id) {
  170. getBargainInfo(this.bargainorder_info.bargain_id).then(res => {
  171. this.dialog={mode:'input',title:'请填写购买数量',content:'不可超过' + res.result.bargain_info.bargain_limit,inputType: 'number',data:res.result}
  172. this.$refs.confirm.open()
  173. }).catch(function (error) {
  174. uni.showToast({icon:'none',title: error.message})
  175. })
  176. }
  177. return
  178. }
  179. if (this.user && this.user.member_id == this.bargainorder_info.bargainorder_initiator_id) {
  180. this.showPopup('posterVisible')
  181. } else {
  182. addBargainLog(this.bargainorder_id).then(res => {
  183. this.getBargainOrderInfo()
  184. }).catch(function (error) {
  185. uni.showToast({icon:'none',title: error.message})
  186. })
  187. }
  188. },
  189. /*
  190. * timeDown: 倒计时
  191. */
  192. timeDown () {
  193. let end_time = false
  194. if (this.bargainorder_info) {
  195. end_time = this.bargainorder_info.bargainorder_endtime
  196. }
  197. if (end_time) {
  198. const endTime = new Date(end_time * 1000)
  199. const nowTime = new Date()
  200. let leftTime = parseInt((endTime.getTime() - nowTime.getTime()) / 1000)
  201. this.hours = this.formate(parseInt((leftTime / (60 * 60)) % 24))
  202. this.minute = this.formate(parseInt((leftTime / 60) % 60))
  203. this.second = this.formate(parseInt(leftTime % 60))
  204. if (leftTime <= 0) {
  205. this.flag = false
  206. }
  207. }
  208. },
  209. /*
  210. * 格式化时间
  211. */
  212. formate (time) {
  213. if (time >= 10) {
  214. return time
  215. } else {
  216. return `0${time}`
  217. }
  218. }
  219. }
  220. }
  221. </script>
  222. <style scoped lang="scss">
  223. @keyframes scaleDraw {0% {transform: scale(1);}
  224. 25% {transform: scale(1.05);}
  225. 50% {transform: scale(1);}
  226. 75% {transform: scale(1.05);}}
  227. @keyframes scrollText10 {0% {transform: translateY(0px);}
  228. 10% {transform: translateY(-2.5rem);}
  229. 20% {transform: translateY(-5rem);}
  230. 30% {transform: translateY(-7.5rem);}
  231. 40% {transform: translateY(-10rem);}
  232. 50% {transform: translateY(-12.5rem);}
  233. 60% {transform: translateY(-15rem);}
  234. 70% {transform: translateY(-17.5rem);}
  235. 80% {transform: translateY(-20rem);}
  236. 90% {transform: translateY(-22.5rem);}
  237. 100% {transform: translateY(-25rem);}}
  238. @keyframes scrollText9 {0% {transform: translateY(0px);}
  239. 11.1111% {transform: translateY(-2.5rem);}
  240. 22.2222% {transform: translateY(-5rem);}
  241. 33.3333% {transform: translateY(-7.5rem);}
  242. 44.4444% {transform: translateY(-10rem);}
  243. 55.5555% {transform: translateY(-12.5rem);}
  244. 66.6666% {transform: translateY(-15rem);}
  245. 77.7777% {transform: translateY(-17.5rem);}
  246. 88.8888% {transform: translateY(-20rem);}
  247. 99.9999% {transform: translateY(-22.5rem);}}
  248. @keyframes scrollText8 {0% {transform: translateY(0px);}
  249. 12.5% {transform: translateY(-2.5rem);}
  250. 25% {transform: translateY(-5rem);}
  251. 37.5% {transform: translateY(-7.5rem);}
  252. 50% {transform: translateY(-10rem);}
  253. 62.5% {transform: translateY(-12.5rem);}
  254. 75% {transform: translateY(-15rem);}
  255. 87.5% {transform: translateY(-17.5rem);}
  256. 100% {transform: translateY(-20rem);}}
  257. @keyframes scrollText7 {0% {transform: translateY(0px);}
  258. 14.2857% {transform: translateY(-2.5rem);}
  259. 28.5714% {transform: translateY(-5rem);}
  260. 42.8571% {transform: translateY(-7.5rem);}
  261. 57.1428% {transform: translateY(-10rem);}
  262. 71.4285% {transform: translateY(-12.5rem);}
  263. 85.7142% {transform: translateY(-15rem);}
  264. 99.9999% {transform: translateY(-17.5rem);}}
  265. @keyframes scrollText6 {0% {transform: translateY(0px);}
  266. 16.6666% {transform: translateY(-2.5rem);}
  267. 33.3332% {transform: translateY(-5rem);}
  268. 49.9998% {transform: translateY(-7.5rem);}
  269. 66.6664% {transform: translateY(-10rem);}
  270. 83.333% {transform: translateY(-12.5rem);}
  271. 99.9996% {transform: translateY(-15rem);}}
  272. @keyframes scrollText5 {0% {transform: translateY(0px);}
  273. 20% {transform: translateY(-2.5rem);}
  274. 40% {transform: translateY(-5rem);}
  275. 60% {transform: translateY(-7.5rem);}
  276. 80% {transform: translateY(-10rem);}
  277. 100% {transform: translateY(-12.5rem);}}
  278. @keyframes scrollText4 {0% {transform: translateY(0px);}
  279. 25% {transform: translateY(-2.5rem);}
  280. 50% {transform: translateY(-5rem);}
  281. 75% {transform: translateY(-7.5rem);}
  282. 100% {transform: translateY(-10rem);}}
  283. .whole-wrapper{position:fixed;width:100%;height: 100%;background-color: #EA3F64;overflow: auto}
  284. .bargain-share {background-color: #EA3F64;background-repeat: no-repeat;background-size: 100%;background-position: top center;position: relative;padding-top: 1rem ;padding-bottom: 3rem;}
  285. .bargain-share.inactive{color: #a1a1a1}
  286. .bargain-share.inactive .bargain-info .bargain_remark{color: #a1a1a1}
  287. .bargain-share.inactive .bargain-info .goods_info .bargain_goods_price{color: #a1a1a1}
  288. .bargain-share.inactive .expired{color:red;border:2px solid red;padding:.2rem;font-weight: bold;display: inline-block;position: absolute;right:.5rem;bottom:1rem;transform: rotate(-30deg)}
  289. .bargain-info,.bargain-order,.bargain-log {padding: 1rem;background: #fff;width: 88%;margin: 1rem auto 0;position: relative;border-radius: 0.4rem;font-size:$fontSize;box-sizing: border-box}
  290. .bargain-info .member_avatar {position: absolute;left: 50%;transform: translateX(-50%);top: -1.5rem;text-align: center;}
  291. .bargain-info .member_avatar .img {width: 3rem;height: 3rem;max-width: 100%;max-height: 100%;vertical-align: middle;border-radius: 50%;}
  292. .bargain-info .member_name {text-align: center;margin-top: 0.6rem;line-height: 1rem;font-size:$subFontSize;}
  293. .bargain-info .bargain_remark {text-align: center;line-height: 1.5rem;font-size:$subFontSize;color: #9a6e3a}
  294. .bargain-info .goods_info {height: 4rem;display: flex;margin-bottom: 1rem;}
  295. .bargain-info .goods_info .p_img {}
  296. .bargain-info .goods_info .p_img .img {width: 4rem;height: 4rem;}
  297. .bargain-info .goods_info .p_info {position: relative;height: 4rem}
  298. .bargain-info .goods_info .goods_name {line-height: 1rem;height: 2rem;overflow: hidden;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;line-clamp: 2;box-orient: vertical;}
  299. .bargain-info .goods_info .bargain_goods_price {line-height: 1rem;color: red;position: absolute;bottom: 0}
  300. .bargain-info .goods_info .bargain_goods_price .em {font-size:$h2;}
  301. .bargain-info .goods_info .bargain_goods_price del {color: #a1a1a1;margin-left: .2rem;}
  302. .bargain-order {text-align: center;padding-top: 1rem;padding-bottom: 1rem;}
  303. .bargain-order .count {background: #ffeff2;color: #f12c56;padding: 0 1rem;border-radius: 1.5rem;height: 1.5rem;line-height: 1.5rem;box-sizing: border-box;display: inline-block}
  304. .bargain-order .notice {color: gray;}
  305. .bargain-log {}
  306. .bargain-log .title {text-align: center;color: #f12c56}
  307. .bargain-log .scroll-wrapper {overflow: hidden;height: 7.5rem;}
  308. .bargain-log .null{padding:1rem;color:gray;text-align: center}
  309. .bargain-log .ul {top: 0;position: relative;}
  310. .bargain-log .ul.line-10{-webkit-animation: scrollText10 20s infinite cubic-bezier(1,0,0.5,0);animation: scrollText10 20s infinite cubic-bezier(1,0,0.5,0);}
  311. .bargain-log .ul.line-9{-webkit-animation: scrollText9 18s infinite cubic-bezier(1,0,0.5,0);animation: scrollText9 18s infinite cubic-bezier(1,0,0.5,0);}
  312. .bargain-log .ul.line-8{-webkit-animation: scrollText8 16s infinite cubic-bezier(1,0,0.5,0);animation: scrollText8 16s infinite cubic-bezier(1,0,0.5,0);}
  313. .bargain-log .ul.line-7{-webkit-animation: scrollText7 14s infinite cubic-bezier(1,0,0.5,0);animation: scrollText7 14s infinite cubic-bezier(1,0,0.5,0);}
  314. .bargain-log .ul.line-6{-webkit-animation: scrollText6 12s infinite cubic-bezier(1,0,0.5,0);animation: scrollText6 12s infinite cubic-bezier(1,0,0.5,0);}
  315. .bargain-log .ul.line-5{-webkit-animation: scrollText5 10s infinite cubic-bezier(1,0,0.5,0);animation: scrollText5 10s infinite cubic-bezier(1,0,0.5,0);}
  316. .bargain-log .ul.line-4{-webkit-animation: scrollText4 8s infinite cubic-bezier(1,0,0.5,0);animation: scrollText4 8s infinite cubic-bezier(1,0,0.5,0);}
  317. .bargain-log .li {height: 2rem;line-height: 2rem;width: 100%;overflow: hidden;margin: 0.5rem 0;}
  318. .bargain-log .li .p_img {float: left;}
  319. .bargain-log .li .p_img .img {width: 2rem;height: 2rem;border-radius: 50%;}
  320. .bargain-log .li .p_name {float: left;margin-left: 1rem;}
  321. .bargain-log .li .p_price {float: right;}
  322. .bargain-log .li .p_price .em {color: red;}
  323. .bargain-order .connect-wrapper {position: absolute;height: 2.5rem;top: -1.75rem;z-index: 2}
  324. .bargain-order .connect-wrapper .dot {width: .5rem;height: .5rem;border-radius: 50%;background: #EA3F64}
  325. .bargain-order .connect-wrapper .bottom-dot {bottom: 0;position: absolute;}
  326. .bargain-order .connect-wrapper .round {width: .3rem;height: 2rem;background: #FF8C00;border-radius: .3rem;position: absolute;top: .25rem;left: .1rem;}
  327. .bargain-order .connect-wrapper.right {right: 10px;}
  328. .bargain-order .button-1 {background:#999 !important;width: 100%;font-size:$fontSize;height: 2rem;line-height: 2rem;border-radius: 2rem;box-shadow: 0px 5px 10px 0px #c3c3c3;}
  329. .bargain-order .button-1 .gloss {display: none;position: absolute;z-index: 1;left: .8rem;top: .2rem;height: .3rem;width: 5rem;opacity: .8;}
  330. .bargain-order .button-1.active{-webkit-animation: scaleDraw 2s ease-in-out infinite;background: #EA3F64 !important;background-image: linear-gradient(to right, #ff5e00, #ea3f3f) !important;}
  331. .bargain-order .button-1.active .gloss{display: block}
  332. .progress-wrapper {position: relative;width: 100%}
  333. .progress-wrapper .progress-back {background: #ffeff2;width: 100%;height: .3rem;border-radius: .3rem;}
  334. .progress-wrapper .progress-front {background: #f12c56;width: 0%;height: .3rem;border-radius: .3rem;position: absolute;}
  335. .progress-wrapper .progress-front .arrow {position: absolute;right: 0;background: #f12c56;text-align: center;height: .8rem;width: .8rem;border-radius: 50%;line-height: .8rem;font-size:$fontSize;top: -.25rem;}
  336. .progress-wrapper .progress-front .arrow:before {width: .3rem;height: .3rem;background: #ffeff2;content: "";display: block;margin: .25rem auto;border-radius: 50%;}
  337. .count-down-wrapper {color: #f12c56;line-height: 1rem;}
  338. .count-down-wrapper .block {display: inline-block;width: 1rem;height: 1rem;border-radius: .2rem;color: #fff;line-height: 1rem;background: #f12c56;margin: 0 .2rem;vertical-align: middle}
  339. .poster-img{width:8rem;height:8rem;}
  340. </style>