CheckoutStore.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <view class="div container" v-if="addressApi">
  3. <view class="div" v-for="(store,index) in storeCartList" :key="index">
  4. <view class="div cart-item" :show-border="true">
  5. <view class="div">
  6. <view class="div store">
  7. <text class="i iconfont">&#xe62d;</text>
  8. <text class="span" @click="goNavigate('/pages/home/storedetail/Storedetail',{ id: store.store_id })">{{store.store_name}}</text>
  9. </view>
  10. <view class="div buy-item" v-for="(goods,index) in store.goods_list" :key="index">
  11. <view class="div goods-pic"><image mode="aspectFit" class="img" :src="goods.goods_image_url" @click="goNavigate('/pages/home/goodsdetail/Goodsdetail',{goods_id:goods.goods_id})"/></view>
  12. <view class="div goods-info">
  13. <view class="dl">
  14. <view class="dt goods-name">
  15. <text class="i tag-icon" v-if="goods.xianshi_info">{{goods.xianshi_info.xianshi_title}}</text>
  16. <text class="i tag-icon" v-if="goods.ifgroupbuy">抢购</text>
  17. <text class="i tag-icon" v-if="goods.ifmgdiscount">会员折扣</text>
  18. <text class="i tag-icon" v-if="goods.ifpintuan">拼团</text>
  19. <text class="i tag-icon" v-if="goods.ifbargain">砍价</text>
  20. <text class="i tag-icon" v-if="goods.bl_id">优惠套装</text>
  21. {{goods.goods_name}}
  22. </view>
  23. <view class="dd goods-subtotal">
  24. <text class="span goods-price">¥{{goods.goods_price}}</text><text v-if="goods.goods_price<goods.goods_original_price" class="span ml-5 goods-original-price">¥{{goods.goods_original_price}}</text>
  25. <text class="span goods-count">×{{goods.goods_num}}</text>
  26. </view>
  27. <view class="dd">
  28. <view class="div link" v-if="goodsCount>1 && chainList[goods.goods_id] && chainList[goods.goods_id].length" @click="goBuy(goods.goods_id,goods.goods_num)">当前地区可以使用自提点(选择自提点后只能单个商品结算)</view>
  29. <view class="div" v-else>
  30. <view class="div link" v-if="addressApi.allow_offpay==1 && ifshowOffpay && offlineList[goods.goods_id]">该商品支持货到付款</view>
  31. </view>
  32. <view class="div link" v-if="goods.limit == true">该商品不支持配送到此收货地址</view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="div buy-item" v-if="store.store_mansong_rule_list && store.store_mansong_rule_list.goods_id !=0 && store.store_mansong_rule_list.mansong_goods_name !=''" @click="goNavigate('/pages/home/goodsdetail/Goodsdetail',{goods_id:store.store_mansong_rule_list.goods_id})">
  38. <view class="div goods-pic"><image mode="aspectFit" class="img" :src="store.store_mansong_rule_list.goods_image_url"/></view>
  39. <view class="div goods-info">
  40. <view class="dl">
  41. <view class="dt goods-name">
  42. <text class="i tag-icon">赠品</text>
  43. {{store.store_mansong_rule_list.mansong_goods_name}}
  44. </view>
  45. <view class="dd goods-subtotal">
  46. <text class="span goods-price">¥0.00</text>
  47. <text class="span goods-count">×1</text>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="div cart-subtotal">
  55. <view class="div" v-if="chainCount[store.store_id]>0" @click="showChain(store.store_id)">
  56. <flex-line class="menu-item" :is-link="true" :show-border="true">
  57. <view class="div">
  58. <text class="span left-icon iconfont">&#xe6d3;</text>
  59. <text class="span">自提门店</text>
  60. </view>
  61. <text class="span" slot="right">{{chainInfo[store.store_id]?chainInfo[store.store_id].chain_addressname:'请选择'}}</text>
  62. </flex-line>
  63. </view>
  64. <view class="div" v-if="store.store_voucher_list.length" @click="showVoucher(store.store_id)">
  65. <flex-line class="menu-item" :is-link="true" :show-border="true">
  66. <view class="div">
  67. <text class="span left-icon iconfont">&#xe6f2;</text>
  68. <text class="span">代金券</text>
  69. </view>
  70. <text class="span" slot="right">{{myVoucher[store.store_id]}}</text>
  71. </flex-line>
  72. </view>
  73. <view class="div message">
  74. <view class="div field-line-right" ><textarea class="order-message field-input" @change="changeMessage(store.store_id)" v-model="message[store.store_id]" placeholder="店铺订单留言:" ></textarea></view>
  75. </view>
  76. <checkout-desc class="desc-item mt-5" title="商品金额" :subtitle="store.store_goods_original_total"></checkout-desc>
  77. <checkout-desc class="desc-item" title="优惠" v-if="store.store_mansong_rule_list || store.store_goods_discount_total>0" :subtitle="Math.round(((store.store_mansong_rule_list.discount?parseFloat(store.store_mansong_rule_list.discount):0)+parseFloat(store.store_goods_discount_total))*100)/100" :discount="true"></checkout-desc>
  78. <checkout-desc class="desc-item" title="运费" :subtitle="chainInfo[store.store_id]?0:(addressApi.state == 'fail'?0:addressApi.content[store.store_id])"></checkout-desc>
  79. <checkout-desc class="desc-item" title="本店合计" :subtitle="totalAmount[store.store_id]"></checkout-desc>
  80. </view>
  81. <uni-popup background-color="#fff" :ref="'voucherVisible_'+store.store_id" type="right" >
  82. <view :style="'width:'+screenWidth+'px'" class="common-popup-wrapper">
  83. <view class="div common-header-wrap">
  84. <view :style="'height:'+navHeight+'px'"></view>
  85. <view class="common-header-holder"></view>
  86. <view class="common-header-fixed">
  87. <title-header />
  88. <uni-nav-bar title="代金券" class="common-header" left-icon="back" @clickLeft="hideVoucher(store.store_id)">
  89. <view class="div common-btn btn" slot="right" @click="selectVoucher('',store.store_id)">不使用</view>
  90. </uni-nav-bar>
  91. </view>
  92. </view>
  93. <view class="div common-popup-content">
  94. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" scroll-y="true">
  95. <view class="div common-voucher common-voucher02" :class="(item.voucher_state != 1)?'disable':''" v-for="(item,index) in store.store_voucher_list" :key="item.voucher_id" @click="selectVoucher(item,store.store_id)">
  96. <view class="div par"><view class="p">订单满{{item.voucher_limit}}元</view><text class="sub sign">¥</text><text class="span">{{item.voucher_price}}</text></view>
  97. <view class="div copy">有效期至<view class="p"><br>{{$moment.unix(item.voucher_enddate).format('YYYY.MM.DD')}}</view></view>
  98. <text class="i"></text>
  99. </view>
  100. </scroll-view>
  101. </view>
  102. </view>
  103. </uni-popup>
  104. <uni-popup background-color="#fff" :ref="'chainVisible_'+store.store_id" type="right" >
  105. <view :style="'width:'+screenWidth+'px'" class="common-popup-wrapper">
  106. <view class="div common-header-wrap">
  107. <view :style="'height:'+navHeight+'px'"></view>
  108. <view class="common-header-holder"></view>
  109. <view class="common-header-fixed">
  110. <title-header />
  111. <uni-nav-bar title="自提门店" class="common-header" left-icon="back" @clickLeft="hideChain(store.store_id)">
  112. <view class="div common-btn btn" slot="right" @click="selectChain('',store.store_id)">不使用</view>
  113. </uni-nav-bar>
  114. </view>
  115. </view>
  116. <view class="div common-popup-content">
  117. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" scroll-y="true">
  118. <view class="div chain-item" v-for="(chain,i) in chainList[store.store_id]" :key="i" @click="selectChain(chain,store.store_id)">
  119. <view class="div chain-name">{{chain.chain_addressname}}</view>
  120. <view class="div chain-desc">{{chain.chain_area_info}}{{chain.chain_address}}</view>
  121. </view>
  122. </scroll-view>
  123. </view>
  124. </view>
  125. </uni-popup>
  126. </view>
  127. </view>
  128. </template>
  129. <script>
  130. import TitleHeader from '../../../TitleHeader'
  131. import { urlencode } from '@/util/common'
  132. import { getbuyChainList } from '../../../../api/memberBuy'
  133. import CheckoutDesc from './CheckoutDesc'
  134. import flexLine from '../../../flexLine'
  135. export default {
  136. name: 'CheckoutStore',
  137. data(){
  138. return {
  139. navHeight: 0,
  140. screenWidth:0,
  141. totalAmount: {},
  142. myVoucher: [],
  143. message: [],
  144. chainList: {},
  145. offlineList: {},
  146. goodsCount: 0,
  147. chainCount: [],
  148. chainInfo: [],
  149. goodsInfo: false
  150. }
  151. },
  152. components:{
  153. TitleHeader,
  154. flexLine,
  155. CheckoutDesc
  156. },
  157. props: ['payGoodsList', 'addressInfo', 'storeCartList', 'addressApi', 'finalTotalList', 'ifshowOffpay'],
  158. created: function () {
  159. if (this.payGoodsList.offline) {
  160. var offlineList = {}
  161. for (var i in this.payGoodsList.offline) {
  162. offlineList[this.payGoodsList.offline[i].goods_id] = 1
  163. }
  164. this.offlineList = offlineList
  165. }
  166. for (var store_id in this.storeCartList) {
  167. this.calcOrder(store_id)
  168. if (this.addressInfo) {
  169. var goods_list = JSON.stringify(this.storeCartList[store_id].goods_list)
  170. this.getbuyChainList(goods_list, this.addressInfo.area_id,store_id)
  171. }
  172. }
  173. },
  174. mounted(){
  175. // #ifdef MP-WEIXIN
  176. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  177. // #endif
  178. this.screenWidth=uni.getSystemInfoSync().screenWidth
  179. },
  180. methods:{
  181. goNavigate(path,query=false){
  182. uni.navigateTo({url:path+(query?('?'+urlencode(query)):'')})
  183. },
  184. showPopup(id){
  185. this.$refs[id][0].open()
  186. },
  187. hidePopup(id){
  188. this.$refs[id][0].close()
  189. },
  190. goBuy (goods_id, goods_num) {
  191. var params = { buy_now: 1, cart_id: goods_id + '|' + goods_num }
  192. uni.navigateTo({ url: '/pages/member/buy/step1'+'?'+urlencode( params )})
  193. },
  194. selectChain (chain,store_id) {
  195. if(chain === ''){
  196. this.chainInfo[store_id] = ''
  197. }else{
  198. this.chainInfo[store_id] = chain
  199. }
  200. this.calcOrder(store_id)
  201. this.$emit('selectChain', this.chainInfo, store_id)
  202. this.hideChain(store_id)
  203. this.$forceUpdate()
  204. },
  205. getbuyChainList (goods_list, area_id,store_id) {
  206. getbuyChainList( goods_list, area_id ).then(res => {
  207. this.chainList[store_id] = res.result.chain_list
  208. this.chainCount[store_id] = this.chainList[store_id].length
  209. this.$forceUpdate()
  210. })
  211. },
  212. changeMessage (store_id) {
  213. this.$emit('changeMessage', this.message[store_id], store_id)
  214. },
  215. selectVoucher (voucherInfo, store_id) {
  216. this.hideVoucher(store_id)
  217. this.$emit('selectVoucher', voucherInfo, store_id)
  218. this.storeCartList[store_id].store_voucher_info = voucherInfo
  219. this.calcOrder(store_id)
  220. },
  221. calcOrder (store_id) {
  222. let price = parseFloat(this.finalTotalList[store_id])
  223. if (this.storeCartList[store_id].store_voucher_list.length) {
  224. if (this.storeCartList[store_id].store_voucher_info) {
  225. price -= parseFloat(this.storeCartList[store_id].store_voucher_info.voucher_price)
  226. if (typeof (this.myVoucher[store_id]) === 'undefined') {
  227. this.myVoucher[store_id] = ''
  228. }
  229. this.myVoucher.splice(store_id, 1, this.storeCartList[store_id].store_voucher_info.voucher_price + '元')
  230. } else {
  231. this.myVoucher.splice(store_id, 1, '不使用')
  232. }
  233. }
  234. if (this.chainInfo[store_id]) {
  235. price -= this.addressApi.content[store_id]
  236. }
  237. if (price < 0) {
  238. price = 0
  239. }
  240. this.totalAmount[store_id] = Math.round(price * 100) / 100
  241. },
  242. showVoucher (store_id) {
  243. this.$refs['voucherVisible_'+store_id][0].open()
  244. },
  245. hideVoucher (store_id) {
  246. this.$refs['voucherVisible_'+store_id][0].close()
  247. },
  248. showChain (store_id) {
  249. this.$refs['chainVisible_'+store_id][0].open()
  250. },
  251. hideChain (store_id) {
  252. this.$refs['chainVisible_'+store_id][0].close()
  253. }
  254. }
  255. }
  256. </script>
  257. <style scoped lang="scss">
  258. .common-header{
  259. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  260. }
  261. .container{background: #fff;padding:0 $pageSpace}
  262. .store{ position: relative;
  263. z-index: 1;
  264. display: block;
  265. height: 0.9rem;
  266. padding: 0.5rem 0;
  267. font-size:$subFontSize;
  268. line-height: 0.9rem;
  269. background: #fff;
  270. font-weight: 700;
  271. }
  272. .store .i{
  273. font-size: $h2;
  274. margin-right: 0.2rem;
  275. color:$primaryColor;
  276. }
  277. .cart-item{background-color: #FFF;}
  278. .buy-item{ display: block;
  279. position: relative;
  280. z-index: 1;
  281. margin:.5rem 0;
  282. box-shadow: 0px 4px 4px #f7f7f7;
  283. }
  284. .buy-item .goods-pic{display: block;
  285. width: 3rem;
  286. height: 3rem;
  287. position: absolute;
  288. z-index: 1;
  289. top: 0rem;
  290. left: 0rem;
  291. }
  292. .buy-item .goods-pic .img{width:100%;
  293. height:100%;border-radius: 0.2rem;}
  294. .buy-item .goods-info{ display: block;
  295. vertical-align: top;
  296. min-height: 3.1rem;
  297. margin-left:4rem;
  298. position: relative;
  299. z-index: 1;}
  300. .buy-item .goods-info .link{font-size:$subFontSize;color:$primaryColor;margin-top:.3rem}
  301. .buy-item .goods-info .goods-name {
  302. height:1.6rem;
  303. font-size:$subFontSize;
  304. line-height: .8rem;
  305. overflow: hidden;
  306. display: -webkit-box;
  307. -webkit-line-clamp: 2;
  308. -webkit-box-orient: vertical;
  309. line-clamp: 2;
  310. box-orient: vertical;
  311. margin-bottom:.5rem;
  312. font-weight: normal;
  313. .tag-icon{vertical-align: top}
  314. }
  315. .buy-item .goods-info .goods-type {
  316. overflow: hidden;
  317. white-space: nowrap;
  318. width: 70%;
  319. height: 0.9rem;
  320. font-size: $h6;
  321. line-height: 0.9rem;
  322. color: #999;
  323. text-overflow: ellipsis;
  324. }
  325. .buy-item .goods-info .goods-original-price{text-decoration: line-through;font-size:$fontSize;color:$descTextColor;font-weight: normal}
  326. .buy-item .goods-info .goods-subtotal {
  327. display: block;
  328. height: 1rem;
  329. margin: 0 0.5rem 0 0rem;
  330. line-height: 1rem;
  331. font-size:$subFontSize;
  332. position: relative;
  333. z-index: 1;
  334. }
  335. .buy-item .goods-info .goods-subtotal .goods-price {
  336. color: #DB4453;
  337. font-size:$subFontSize;
  338. font-weight: 600;
  339. }
  340. .buy-item .goods-info .goods-subtotal .goods-count {
  341. font-size:$subFontSize;
  342. line-height: 1rem;
  343. position: absolute;
  344. z-index: 1;
  345. top: 0rem;
  346. right: 0rem;
  347. font-weight: normal;
  348. color:$descTextColor
  349. }
  350. .cart-subtotal{}
  351. .cart-subtotal .dl {
  352. position: relative;
  353. z-index: 1;
  354. height: 1rem;
  355. padding: 0.4rem 0 0;
  356. font-size: 0;
  357. }
  358. .cart-subtotal .dt {
  359. position: absolute;
  360. z-index: 1;
  361. top: 0.4rem;
  362. left: 0.4rem;
  363. display: block;
  364. width: 50%;
  365. height: 1rem;
  366. font-size:$fontSize;
  367. line-height: 1rem;
  368. }
  369. .cart-subtotal .dd {
  370. height: 1rem;
  371. margin: 0 0.5rem 0 50%;
  372. text-align: right;
  373. font-size:$fontSize;
  374. line-height: 1rem;
  375. }
  376. .cart-subtotal .message {
  377. position: relative;
  378. z-index: 1;
  379. display: block;
  380. border-bottom: 1px dashed #eee;
  381. .order-message{background: #FBFBFB;margin:.5rem 0;font-size:$fontSize;padding:.5rem;height: 4rem;border: 0;box-sizing: border-box;width: 100%;}
  382. }
  383. .desc-item {
  384. height: 1.5rem;
  385. }
  386. .common-voucher{margin:0.5rem auto}
  387. .left-icon{float:left;font-size:$h1;margin-right:0.2rem;}
  388. .chain-item{padding:.5rem;}
  389. .chain-item .chain-name{font-size:$h2;margin-bottom:.3rem}
  390. .chain-item .chain-desc{font-size:$fontSize;color:#666}
  391. .field-line-right{
  392. .field-input{
  393. text-align: left !important;
  394. }
  395. }
  396. </style>