InfoItem.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <!-- Detailinfo.vue -->
  2. <template>
  3. <view class="div" v-if="detailInfo">
  4. <view v-if="detailInfo.bargain_info" class="div bargain-wrapper">
  5. <view class="div bargain-content" @click="showPopup('bargainVisible')">
  6. <view class="div title">砍价购</view>
  7. <view class="div content">
  8. <view class="div">距结束仅剩</view>
  9. <view class="div"><text class="span" v-if="day"><text class="em">{{day}}</text>天</text><text class="span"><text class="em">{{hours}}</text>时</text><text class="span"><text class="em">{{minute}}</text>分</text><text class="span"><text class="em">{{second}}</text>秒</text></view>
  10. </view>
  11. <view class="div arrow iconfont">&#xe650;</view>
  12. </view>
  13. <uni-popup background-color="#fff" ref="bargainVisible" type="bottom" class="bargain-popup-wrapper">
  14. <view class="div mt">玩法详情</view>
  15. <view class="div mc">
  16. <view class="div line">
  17. 1.活动期间消费者可邀请好友帮忙砍价,好友砍到底价后,即可按底价购买商品;
  18. </view>
  19. <view class="div line">
  20. 2.好友帮忙砍到底价后,消费者须在有效期内购买砍价商品,逾期商品将恢复原价;
  21. </view>
  22. <view class="div line">
  23. 3.同一商品,同一用户仅可享受一次优惠价格;
  24. </view>
  25. <view class="div line">
  26. 4.同一商品,同一用户仅能帮好友砍价一次;
  27. </view>
  28. <view class="div line">
  29. 5.砍价商品数量有限,商品售罄后,您将无法购买。
  30. </view>
  31. </view>
  32. </uni-popup>
  33. </view>
  34. <view class="div ui-detail-info">
  35. <view class="div info-header ui-flex">
  36. <text class="h3">{{ detailInfo.goods_name }}</text>
  37. <view class="div favorite">
  38. <text class="i iconfont" v-on:click="productUnlike()" v-if="isFavorate">&#xe6d5;</text>
  39. <text class="i iconfont" v-on:click="productLike()" v-else>&#xe6d6;</text>
  40. <text class="span">{{favoriteName}}</text>
  41. </view>
  42. </view>
  43. <view class="div goods_advword" v-if="detailInfo.goods_advword"><text class="span strong">{{ detailInfo.goods_advword }}</text></view>
  44. <view v-if="detailInfo.wholesale_info" class="div price" style="display: flex">
  45. <view class="div" v-for="(item,index) in detailInfo.wholesale_info.wholesalegoods_price" :key="index" style="flex:1">
  46. <text class="span current-price">¥<text class="i price-number">{{item.price}}</text></text>
  47. <text class="span num">{{item.num_text}}</text>
  48. </view>
  49. </view>
  50. <view v-else class="div price">
  51. <text class="span current-price">¥<text class="i price-number"><slot v-if="detailInfo.bargain_info">{{ detailInfo.bargain_info.bargain_floorprice }}</slot><slot v-else-if="detailInfo.pintuan_type">{{ detailInfo.pintuan_price }}</slot><slot v-else-if="detailInfo.promotion_type">{{ detailInfo.promotion_price }}</slot><slot v-else>{{ detailInfo.goods_price }}</slot></text>
  52. </text>
  53. <text class="span old-price" v-if="detailInfo.goods_marketprice > 0">¥{{ detailInfo.goods_marketprice }}</text>
  54. </view>
  55. <view class="div inviter_amount" v-if="detailInfo.inviter_money > 0">
  56. <text class="span inviter_amount" >分销佣金:¥{{ detailInfo.inviter_money }}</text>
  57. </view>
  58. <view class="div" v-if="!detailInfo.bargain_info">
  59. <view class="div info-promotions" v-if="detailInfo.pintuan_type=='pintuan'">
  60. <view class="div left">
  61. <text class="i">拼团</text>
  62. <text class="span" v-if="detailInfo.pintuan_limit_quantity">最多可购买{{detailInfo.pintuan_limit_quantity}}件</text>
  63. </view>
  64. <text class="span right">{{fromNow(detailInfo.pintuan_end_time)}}结束</text>
  65. </view>
  66. <view class="div info-promotions" v-if="detailInfo.promotion_type=='groupbuy'">
  67. <view class="div left">
  68. <text class="i">抢购</text>
  69. <text class="span" v-if="detailInfo.upper_limit">最多可购买{{detailInfo.upper_limit}}件</text>
  70. </view>
  71. <text class="span right">{{fromNow(detailInfo.promotion_end_time)}}结束</text>
  72. </view>
  73. <view class="div info-promotions" v-if="detailInfo.promotion_type=='xianshi'">
  74. <view class="div left">
  75. <text class="i">秒杀</text>
  76. <text class="span" v-if="detailInfo.lower_limit">最低{{detailInfo.lower_limit}}件起</text>
  77. </view>
  78. <text class="span right">{{fromNow(detailInfo.promotion_end_time)}}结束</text>
  79. </view>
  80. <view class="div info-promotions" v-if="detailInfo.promotion_type=='presell'">
  81. <view class="div left">
  82. <text class="i">预售</text>
  83. <text class="span" v-if="detailInfo.remark">{{detailInfo.remark}}</text>
  84. </view>
  85. <text class="span right">{{fromNow(detailInfo.presell_end_time)}}结束</text>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="div dss-sale main-content" v-if="detailInfo.goods_mgdiscount_arr" @click.native="showPopup('goodsmgdiscountarr')">
  90. <flex-line :is-link="true" :show-border="true" >
  91. <text class="span">会员尊享专属权益</text>
  92. </flex-line>
  93. </view>
  94. <uni-popup background-color="#fff" ref="goodsmgdiscountarr" type="bottom" class="goodsmgdiscountarr-popup-wrapper">
  95. <view class="div mt"><text class="span">会员专属权益</text><text class="iconfont" @click.native="hidePopup('goodsmgdiscountarr')">&#xe65d;</text></view>
  96. <view class="div mc">
  97. <view class="title">会员专属折扣</view>
  98. <view class="div item" v-for="(item,index) in detailInfo.goods_mgdiscount_arr" :key="index"><text class="em">{{item.level_name}}可享受会员权益,</text> 购物享{{item.level_discount}}折</view>
  99. </view>
  100. </uni-popup>
  101. </view>
  102. </template>
  103. <script>
  104. import { mapState, mapMutations } from 'vuex'
  105. import flexLine from '../../../flexLine'
  106. import { productLike, productUnlike } from '../../../../api/homegoodsdetail'
  107. export default {
  108. data () {
  109. return {
  110. flag: false,
  111. day: 0,
  112. hours: 0,
  113. minute: 0,
  114. second: 0,
  115. time: false,
  116. orderTime: '', // 下单时间
  117. arrivalsTime: '', // 到达时间
  118. arrivalsTitle: '', // 到达时间的标题
  119. arrivalsRange: '' // 到达时间区间,
  120. }
  121. },
  122. components: {
  123. flexLine
  124. },
  125. computed: {
  126. ...mapState({
  127. isFavorate: state => state.goodsdetail.isFavorate,
  128. detailInfo: state => state.goodsdetail.detailInfo,
  129. currentProductId: state => state.goodsdetail.currentProductId,
  130. user: state => state.member.info
  131. }),
  132. favoriteName () {
  133. return this.isFavorate ? '已关注' : '关注'
  134. }
  135. },
  136. created () {
  137. },
  138. mounted () {
  139. this.time = setInterval(() => {
  140. if (this.flag == true) {
  141. clearInterval(this.time)
  142. } else {
  143. this.timeDown()
  144. }
  145. }, 1000)
  146. },
  147. methods:{
  148. showPopup(id){
  149. this.$refs[id].open()
  150. },
  151. hidePopup(id){
  152. this.$refs[id].close()
  153. },
  154. ...mapMutations({
  155. saveInfo: 'saveDetailInfo',
  156. changeIndex: 'changeIndex',
  157. saveIsFavorate: 'saveIsFavorate'
  158. }),
  159. fromNow (time) {
  160. return this.$moment(time * 1000).fromNow()
  161. },
  162. /*
  163. * getCommentStatus: 去到评论页面
  164. */
  165. getCommentStatus () {
  166. this.changeIndex(2)
  167. },
  168. /*
  169. * productLike: 收藏商品
  170. */
  171. productLike () {
  172. if (this.user) {
  173. let id = this.detailInfo.goods_id
  174. productLike(id).then(res => {
  175. if (res) {
  176. this.saveIsFavorate(true)
  177. }
  178. }).catch(function (error) {
  179. uni.showToast({icon:'none',title: error.message})
  180. })
  181. } else {
  182. uni.navigateTo({url:'/pages/home/memberlogin/Login'})
  183. }
  184. },
  185. /*
  186. * productUnlike: 取消收藏
  187. */
  188. productUnlike () {
  189. if (this.user) {
  190. let id = this.detailInfo.goods_id
  191. productUnlike(id).then(res => {
  192. if (res) {
  193. this.saveIsFavorate(false)
  194. }
  195. })
  196. } else {
  197. uni.navigateTo({url:'/pages/home/memberlogin/Login'})
  198. }
  199. },
  200. /*
  201. * timeDown: 倒计时
  202. */
  203. timeDown () {
  204. let end_time = false
  205. if (this.detailInfo.bargain_info) {
  206. end_time = this.detailInfo.bargain_info.bargain_endtime
  207. }
  208. if (end_time) {
  209. const endTime = new Date(end_time * 1000)
  210. const nowTime = new Date()
  211. let leftTime = parseInt((endTime.getTime() - nowTime.getTime()) / 1000)
  212. this.day = parseInt(leftTime / (24 * 60 * 60))
  213. this.hours = this.formate(parseInt((leftTime / (60 * 60)) % 24))
  214. this.minute = this.formate(parseInt((leftTime / 60) % 60))
  215. this.second = this.formate(parseInt(leftTime % 60))
  216. if (leftTime <= 0) {
  217. this.flag = true
  218. this.detailInfo.bargain_info = ''
  219. this.saveInfo(this.detailInfo)
  220. }
  221. }
  222. },
  223. /*
  224. * 格式化时间
  225. */
  226. formate (time) {
  227. if (time >= 10) {
  228. return time
  229. } else {
  230. return `0${time}`
  231. }
  232. }
  233. }
  234. }
  235. </script>
  236. <style lang="scss" scoped>
  237. .bargain-wrapper{
  238. .bargain-content{
  239. padding:.5rem;color:#fff;
  240. background: #EA3F64;background-image: linear-gradient(to right, #ff5e00, #ea3f3f);
  241. display: flex;
  242. .title{flex:1;font-size:$h1;line-height: 1.2rem;}
  243. .content{width:auto;font-size:$fontSize;line-height: .6rem;
  244. .em{margin:0 .1rem}
  245. }
  246. .arrow{width:1rem;text-align: right;line-height: 1.2rem;}
  247. }
  248. .bargain-popup-wrapper{padding:.5rem;color:#333;box-sizing: border-box;padding-bottom: 3rem;
  249. .mt{font-size:$h2;text-align: center}
  250. .mc{font-size:$fontSize;
  251. .line{margin-top:.5rem;}
  252. }
  253. }
  254. }
  255. .ui-detail-info {
  256. padding: 0 $pageSpace;
  257. background: #ffffff;
  258. .ui-flex {
  259. display: flex;
  260. /*justify-content: space-between;*/
  261. align-content: center;
  262. align-items: center;
  263. flex-basis: 100%;
  264. width: auto;
  265. }
  266. .info-header {
  267. padding-top: 0.4rem;
  268. .h3 {
  269. color: #333;
  270. font-size:$subFontSize;
  271. padding: 0;
  272. margin: 0;
  273. font-weight: normal;
  274. line-height:1rem;
  275. flex:1;
  276. }
  277. .favorite {
  278. height:2.4rem;
  279. text-align:center;
  280. .i{width:2.4rem;display:block;font-size:1.2rem;line-height:1.2rem;color:$primaryColor;}
  281. .span{font-size:$h6;line-height:1rem;height:1rem;display:block;}
  282. }
  283. }
  284. .goods_advword{font-size:$fontSize;padding:.2rem .4rem;margin-bottom:.5rem;background:$subColor;color:$primaryColor}
  285. .price {
  286. padding-bottom: 0.4rem;
  287. display: flex;
  288. .span {
  289. display: block;
  290. font-weight: normal;
  291. &.current-price {
  292. font-size:$fontSize;
  293. color: $primaryColor;
  294. line-height: 1rem;
  295. .price-number{font-size:$h1;font-weight: bold}
  296. }
  297. &.num{
  298. font-size:$fontSize;
  299. color:#666;
  300. }
  301. &.old-price {
  302. font-size:$fontSize;
  303. color: rgba(164, 170, 179, 1);
  304. line-height: 1rem;
  305. text-decoration: line-through;
  306. margin-left: 0.3rem;
  307. }
  308. }
  309. }
  310. .inviter_amount {
  311. padding-bottom: 0.4rem;
  312. display: flex;
  313. .span {
  314. font-size:$subFontSize;
  315. color: #4e545d;
  316. }
  317. }
  318. .info-sub {
  319. border-bottom: 0.5px solid #e8eaed;
  320. padding-bottom: 0.25rem;
  321. .p {
  322. padding: 0;
  323. margin: 0;
  324. color: $primaryColor;
  325. font-size:$h6;
  326. }
  327. }
  328. .info-promotions {
  329. display: flex;
  330. justify-content: flex-start;
  331. align-content: center;
  332. align-items: center;
  333. padding: 0.75rem 0;
  334. border-bottom: 1px dashed #eee;
  335. line-height:1.5rem;
  336. .span {
  337. margin-left: 0.75rem;
  338. font-size:$fontSize;
  339. color: rgba(143, 142, 148, 1);
  340. }
  341. .img {
  342. width: 30.4rem;
  343. }
  344. }
  345. .info-promotions .i{font-size:$subFontSize;border:1px solid $primaryColor;color:$primaryColor;padding:0.1rem 0.3rem;border-radius:0.1rem;}
  346. .info-promotions .left{flex:1}
  347. .info-promotions .right{width:4rem;text-align: right}
  348. }
  349. .main-content{
  350. background-color: #fff;
  351. padding: 0 $pageSpace;
  352. box-sizing: border-box;
  353. }
  354. .goodsmgdiscountarr-popup-wrapper{
  355. .mt{
  356. display: flex;
  357. height: 2.2rem;
  358. align-items: center;
  359. font-size: .8rem;
  360. color: #333;
  361. padding: 0 $pageSpace;
  362. border-bottom: 1px solid #f2f2f2;
  363. .iconfont{
  364. margin-left: auto;
  365. font-size: 1.2rem;
  366. }
  367. }
  368. .mc{
  369. padding: 0 $pageSpace;
  370. padding-bottom: 2.8rem;
  371. .title{
  372. font-size: .7rem;
  373. color: #333;
  374. margin: .65rem 0 .5rem;
  375. }
  376. .item{
  377. font-size: .7rem;
  378. color: #333;
  379. background-image: linear-gradient(to right, #fefaf4 , #fff3e0);
  380. margin-bottom: .5rem;
  381. padding: .5rem 0rem .5rem .6rem;
  382. border-radius: .25rem;
  383. }
  384. }
  385. }
  386. .dss-sale .mgdiscount-info{margin-top:$modelSpace;background:#fff;font-size:$subFontSize;color:#666;padding: .5rem $pageSpace }
  387. .dss-sale .mgdiscount-info .span{margin-right:.5rem;white-space: nowrap;}
  388. .dss-sale .mgdiscount-info .em{background-image:url(../../../../static/image/home/grade.png);background-repeat:no-repeat;background-position:center;background-size:1rem;text-align:center;color:#fff;padding: .1rem;font-size:$fontSize;width:1rem;height: 1rem;line-height:1rem;display: inline-block;}
  389. </style>