createOrder.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. <template>
  2. <view>
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view>
  6. <!-- 地址 -->
  7. <navigator v-if="tabCurrentIndex == 0" url="/pages/address/address?source=1" class="address-section">
  8. <view class="order-content" v-if="addressData.real_name">
  9. <text class="iconfont iconlocation"></text>
  10. <view class="cen">
  11. <view class="top">
  12. <text class="name">{{ addressData.real_name }}</text>
  13. <text class="mobile">{{ addressData.phone }}</text>
  14. </view>
  15. <text class="address">{{ addressData.province + addressData.city + addressData.district }} {{ addressData.detail }}</text>
  16. </view>
  17. <text class="iconfont iconenter"></text>
  18. </view>
  19. <view class="order-content" v-if="!addressData.real_name">
  20. <view class="addAddress">
  21. <text class="iconfont iconaddition"></text>
  22. <text>添加收货地址</text>
  23. </view>
  24. </view>
  25. <image class="a-bg" :src="addressImg"></image>
  26. </navigator>
  27. <navigator v-if="tabCurrentIndex == 1" url="/pages/shoping/list?type=4" class="address-section">
  28. <view class="order-content" v-if="shopAddress.name">
  29. <text class="iconfont iconlocation"></text>
  30. <view class="cen">
  31. <view class="top">
  32. <text class="name">{{ shopAddress.name }}</text>
  33. <text class="mobile">{{ shopAddress.phone }}</text>
  34. </view>
  35. <text class="address">{{ shopAddress.detailed_address }}</text>
  36. </view>
  37. <text class="iconfont iconenter"></text>
  38. </view>
  39. <view class="order-content" v-if="!shopAddress.name">
  40. <view class="addAddress">
  41. <text class="iconfont iconaddition"></text>
  42. <text>添加收货地址</text>
  43. </view>
  44. </view>
  45. <image class="a-bg" :src="addressImg"></image>
  46. </navigator>
  47. <view class="goods-section" v-for="(ls, ind) in shopList" :key="ind">
  48. <!-- <view class="g-header b-b">
  49. <image class="logo" :src="ls.productInfo.image"></image>
  50. <text class="name">{{ ls.name }}</text>
  51. </view> -->
  52. <!-- 商品列表 -->
  53. <view class="g-item">
  54. <image :src="ls.productInfo.image"></image>
  55. <view class="right">
  56. <text class="title clamp">{{ ls.productInfo.store_name }}</text>
  57. <text class="spec">{{ ls.productInfo.attrInfo ? ls.productInfo.attrInfo.suk : '默认' }}</text>
  58. <view class="price-box">
  59. <text class="price">¥{{ moneyNum(ls.productInfo.attrInfo ? ls.productInfo.attrInfo.price : ls.productInfo.price) }}</text>
  60. <text class="number">{{ 'x ' + ls.cart_num + ls.productInfo.unit_name }}</text>
  61. <!-- <view><text class="price">¥{{lss.price}}</text></view> -->
  62. <!-- <view class="number">
  63. <uni-number-box class="step" :value="lss.number" :index="indx" @eventChange="numberChange"></uni-number-box>
  64. </view> -->
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <!-- 优惠明细 -->
  70. <!-- <view class="yt-list">
  71. <view class="yt-list-cell b-b" @click="toggleMask('show')">
  72. <view class="cell-icon">券</view>
  73. <text class="cell-tit clamp">优惠券</text>
  74. <text class="cell-tip active">选择优惠券</text>
  75. <text class="cell-more wanjia wanjia-gengduo-d"></text>
  76. </view>
  77. <view class="yt-list-cell b-b">
  78. <view class="cell-icon hb">减</view>
  79. <text class="cell-tit clamp">商家促销</text>
  80. <text class="cell-tip disabled">暂无可用优惠</text>
  81. </view>
  82. </view> -->
  83. <!-- 金额明细 -->
  84. <view class="yt-list">
  85. <!-- <view class="yt-list-cell b-b">
  86. <text class="cell-tit clamp">优惠金额</text>
  87. <text class="cell-tip red">-¥35</text>
  88. </view> -->
  89. <view class="yt-list-cell b-b" v-if="integralAll > 0 && !is_change">
  90. <text class="cell-tit clamp">积分抵扣{{ '(当前积分:' + integralAll + ')' }}</text>
  91. <view class="cell-tip"><radio @click="checkedPoints = !checkedPoints" color=" #5dbc7c" :checked="checkedPoints" /></view>
  92. </view>
  93. <view class="yt-list-cell b-b" v-if="inte_top > 0 && !checkedPoints && goodsType != 2">
  94. <text class="cell-tit clamp">抵用金{{ '(可用上限:' + inte_top + ')' }}</text>
  95. <view class="cell-tip"><radio @click="is_change = !is_change" color=" #5dbc7c" :checked="is_change" /></view>
  96. </view>
  97. <view class="yt-list-cell b-b">
  98. <text class="cell-tit clamp">运费</text>
  99. <text class="cell-tip">{{ Postage }}</text>
  100. </view>
  101. <view class="yt-list-cell desc-cell" v-if="tabCurrentIndex == 1">
  102. <text class="cell-tit clamp">姓名</text>
  103. <input class="desc" type="text" v-model="pickUpInfo.real_name" placeholder="收货人姓名" placeholder-class="placeholder" />
  104. </view>
  105. <view class="yt-list-cell desc-cell" v-if="tabCurrentIndex == 1">
  106. <text class="cell-tit clamp">手机</text>
  107. <input class="desc" type="text" v-model="pickUpInfo.phone" placeholder="联系手机号" placeholder-class="placeholder" />
  108. </view>
  109. <view class="yt-list-cell b-b">
  110. <text class="cell-tit clamp">备注</text>
  111. <input class="desc" type="text" v-model="desc" placeholder="备注信息" placeholder-class="placeholder" />
  112. </view>
  113. </view>
  114. <view class="yt-list">
  115. <view class="yt-list-cell b-b">
  116. <text class="cell-tit clamp">商品金额</text>
  117. <text class="cell-tip" v-if="is_consumer == 0">¥{{ payAllMoney }}</text>
  118. <text class="cell-tip" v-if="is_consumer == 1">
  119. <image src="../../static/icon/xfq.png" mode="" class="cell-tip-1"></image>
  120. {{ payAllMoney }}
  121. </text>
  122. <!-- <text class="cell-tip">¥{{ payAllMoney }}</text> -->
  123. </view>
  124. <view class="yt-list-cell b-b" v-if="(checkedPoints || is_change) && integralShow">
  125. <text class="cell-tit clamp">扣除积分</text>
  126. <text class="cell-tip">-¥{{ integralMoney }}</text>
  127. </view>
  128. <view class="yt-list-cell b-b" v-if="!checkedPoints && moneyNum(moneyAll.vipPrice) > 0">
  129. <text class="cell-tit clamp">VIP优惠</text>
  130. <text class="cell-tip">-¥{{ moneyNum(moneyAll.vipPrice) }}</text>
  131. </view>
  132. </view>
  133. <!-- 底部 -->
  134. <view class="footer">
  135. <view class="price-content">
  136. <text>实付款</text>
  137. <text class="price-tip" v-if="is_consumer == 0">¥</text>
  138. <image src="../../static/icon/xfq.png" mode="" v-if="is_consumer == 1" class="price-top-1"></image>
  139. <text class="price">{{ payPrice }}</text>
  140. </view>
  141. <text class="submit" :class="{ submitNo: !payType }" @click="payType ? submit() : ''">提交订单</text>
  142. </view>
  143. <!-- 优惠券面板 -->
  144. <view class="mask" :class="maskState === 0 ? 'none' : maskState === 1 ? 'show' : ''" @click="toggleMask">
  145. <view class="mask-content" @click.stop.prevent="stopPrevent">
  146. <!-- 优惠券页面,仿mt -->
  147. <view class="coupon-item" @click="checkedCp(item)" v-for="(item, index) in couponList" :key="index">
  148. <view class="con">
  149. <view class="left">
  150. <text class="title">{{ item.coupon_title }}</text>
  151. <text class="time">领取时间{{ item.add_time }}</text>
  152. </view>
  153. <view class="right">
  154. <text class="price">{{ moneyNum(item.coupon_price) }}</text>
  155. <text>满{{ moneyNum(item.use_min_price) }}可用</text>
  156. </view>
  157. <view class="circle l"></view>
  158. <view class="circle r"></view>
  159. </view>
  160. <text class="tips">有效期至{{ item.end_time }}</text>
  161. </view>
  162. </view>
  163. </view>
  164. </view>
  165. </template>
  166. <script>
  167. import { confirm } from '@/api/order.js';
  168. import { computedOrderkey } from '@/api/money.js';
  169. import { userinfo } from '@/api/user.js';
  170. import { cartAdd } from '@/api/product.js';
  171. export default {
  172. data() {
  173. return {
  174. addressImg:
  175. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAAAFCAYAAAAaAWmiAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmU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xZnt9BYIeBZm0ap1BO2yHLMOIxjH111chmDocXg9XzZFR4fD74e5cA9GtQEulbLGbfaNMvv4+BfG3hiet9wxlUeDGdDPn68uqXVgVKKezbiBN/HHYoTnrqlORkDx0BHr/ABzVVbknbZysZ3wnRVyda6HU1UIjvpt28p2C+T+GEtYeeEh3jqcdKjl2BcWY65q9UAQb+c6+k3iePnaS+P5Pq8spOJ38fJ09RVI1OFuWo6xtJXSD+J6xh++OHN8PEt8HxtNY4pbAczC+m2Rnh8V3J9Q0Fa4LeG97YQdehj4aoSL9NZiZNMTKStp6g5/x5NsW37vWQaS1WXzPHvjihzYS/lgshbeJ75WySHm7wNXXk8SbK/xutOX4ntHtYRxE0eJn6uARaGf6ie++7GPNxVkf/78AAwCn1+RYqusbZQAAAABJRU5ErkJggg==',
  176. // 当前选中的支付方式
  177. tabCurrentIndex: 0,
  178. navList: [
  179. {
  180. state: 0,
  181. text: '快递配送'
  182. },
  183. {
  184. state: 1,
  185. text: '到店自提'
  186. }
  187. ],
  188. maskState: 0, //优惠券面板显示状态
  189. desc: '', //备注
  190. payType: 1, //1微信 2支付宝
  191. // 优惠券列表
  192. couponList: [],
  193. // 收货地址
  194. addressData: {
  195. real_name: '',
  196. phone: ''
  197. },
  198. // 提货个人信息
  199. pickUpInfo: {
  200. real_name: '',
  201. phone: ''
  202. },
  203. // 店铺地址
  204. shopAddress: {
  205. name: '',
  206. mobile: '',
  207. addressName: '',
  208. address: '',
  209. area: '',
  210. default: false,
  211. id: ''
  212. },
  213. // 商品列表
  214. shopList: [],
  215. // 购物车id
  216. cartId: '',
  217. //购物金额详情
  218. moneyAll: {
  219. storeFreePostage: 0, //邮费优惠
  220. storePostage: 0, //邮费
  221. totalPrice: 0, //总支付金额
  222. vipPrice: 0 //vip优惠价
  223. },
  224. payPrice: 0, //总支付金额
  225. orderKey: '', //订单id
  226. checkedPoints: false, //判断是否积分抵扣
  227. integralAll: 0, //可使用的积分
  228. integralMoney: 0, //积分抵扣金额
  229. integralShow: false, //是否显示积分抵扣金额
  230. payType: true, //是否可支付
  231. system_store: [], //到店自提列表仓库
  232. pinkid: '', //保存拼团商品id
  233. is_change: false, //判断是否全额抵扣0为否1为是
  234. inte_top: 0, //积分抵扣上限
  235. goodsType: 0, //0为普通商品2为拼团1为秒杀
  236. is_consumer: 0, //1为消费券商品
  237. };
  238. },
  239. onLoad(option) {
  240. this.goodsType = option.goodsType || 0;
  241. // 判断是否为拼团商品
  242. if(option.consumer) {
  243. this.is_consumer = option.consumer
  244. }
  245. if (option.type == 'pink') {
  246. this.pinkid = option.pinkId;
  247. this.goodsType = 2;
  248. this.cartAdd(option);
  249. } else {
  250. // 保存当前商品在购物车中的id
  251. this.cartId = option.id;
  252. this.loadData();
  253. }
  254. this.userinfo();
  255. },
  256. watch: {
  257. checkedPoints(newValue, oldValue) {
  258. this.integralShow = false;
  259. this.payMoneyNub();
  260. },
  261. //门店切换
  262. tabCurrentIndex(newValue) {
  263. this.payMoneyNub();
  264. },
  265. // 监听是否全额抵扣
  266. is_change() {
  267. this.integralShow = false;
  268. this.payMoneyNub();
  269. },
  270. // 监听收货地址改变
  271. addressData() {
  272. this.payMoneyNub();
  273. }
  274. },
  275. computed: {
  276. Postage() {
  277. let money = +this.moneyAll.storePostage;
  278. if (money == 0) {
  279. return '免运费';
  280. } else {
  281. return '¥' + money;
  282. }
  283. },
  284. payAllMoney() {
  285. return +this.moneyAll.totalPrice + +this.moneyAll.vipPrice;
  286. }
  287. },
  288. methods: {
  289. // 添加商品到购物车
  290. cartAdd(opt) {
  291. let obj = this;
  292. cartAdd({
  293. cartNum: 1, //商品数量
  294. new: 1, //商品是否新增加到购物车1为不加入0为加入
  295. mer_id: +opt.merid, //商店id
  296. combinationId: +opt.gid, //拼团商品id
  297. productId: +opt.pid, //普通商品id
  298. is_consumer: 0,
  299. // type: obj.is_consumer == 1 ?1: 0
  300. })
  301. .then(function(e) {
  302. let da = e.data;
  303. // 獲取购物车号
  304. obj.cartId = da.cartId;
  305. // 加载数据
  306. obj.loadData();
  307. })
  308. .catch(e => {
  309. console.log(e);
  310. });
  311. },
  312. // 转换字符串为数字
  313. moneyNum: function(value) {
  314. return +value;
  315. },
  316. // 加载用户基础信息
  317. userinfo() {
  318. let obj = this;
  319. userinfo({}).then(({ data }) => {
  320. // 用于保存当前对象,优化加载速度
  321. let ob = obj;
  322. ob.integralAll = data.integral;
  323. // 保存可用积分抵扣上限
  324. ob.inte_top = data.max_shangxian;
  325. // 保存默认提货人姓名
  326. ob.pickUpInfo.real_name = data.nickname;
  327. // 保存默认提货人手机号
  328. ob.pickUpInfo.phone = data.phone;
  329. });
  330. },
  331. // 计算支付金额
  332. payMoneyNub: function() {
  333. return new Promise((resolve, reject) => {
  334. computedOrderkey({
  335. orderkey: this.orderKey,
  336. useIntegral: this.checkedPoints ? 1 : 0,
  337. shipping_type: this.tabCurrentIndex + 1, //1是普通2是门店
  338. is_change: this.is_change ? 1 : 0,
  339. latitude: this.addressData.latitude,
  340. longitude: this.addressData.longitude,
  341. addressId: this.addressData.id,
  342. is_consumer: this.is_consumer
  343. })
  344. .then(({ data }) => {
  345. this.payType = true;
  346. this.integralShow = true;
  347. // 获取支付金额
  348. this.payPrice = +data.result.pay_price;
  349. this.integralMoney = data.result.deduction_price;
  350. // 保存邮费
  351. this.moneyAll.storePostage = data.result.pay_postage;
  352. resolve(true);
  353. })
  354. .catch(e => {
  355. console.log(e);
  356. this.integralShow = false;
  357. this.payType = false;
  358. reject(false);
  359. });
  360. });
  361. },
  362. // 是否使用积分
  363. checkedIntegral() {
  364. this.checkedPoints = !this.checkedPoints;
  365. },
  366. //顶部tab点击
  367. tabClick(index) {
  368. this.tabCurrentIndex = index;
  369. },
  370. //显示优惠券面板
  371. toggleMask(type) {
  372. let timer = type === 'show' ? 10 : 300;
  373. let state = type === 'show' ? 1 : 0;
  374. this.maskState = 2;
  375. setTimeout(() => {
  376. this.maskState = state;
  377. }, timer);
  378. },
  379. // 载入数据
  380. loadData: async function() {
  381. let obj = this;
  382. confirm({ cartId: obj.cartId + '' }).then(({ data }) => {
  383. obj.addressData = data.addressInfo || {};
  384. obj.shopList = data.cartInfo; //商品列表
  385. obj.moneyAll = data.priceGroup; //金额数据
  386. obj.orderKey = data.orderKey; //订单key
  387. (obj.system_store = data.system_store), //到店自提列表
  388. obj.shopAddress = data.system_store //选中的地址
  389. // 计算金额
  390. this.payMoneyNub().then(e => {
  391. this.seriationCode(data.cartInfo);
  392. });
  393. });
  394. },
  395. // 购买数量变化
  396. numberChange(data) {
  397. this.number = data.number;
  398. },
  399. // 修改支付方式
  400. changePayType(type) {
  401. this.payType = type;
  402. },
  403. // 判断是否为公排号订单
  404. seriationCode(arr) {
  405. for (var i = 0; i < arr.length; i++) {
  406. if (arr[i].productInfo.is_platoon == 1 && arr.length > 1) {
  407. this.payType = false;
  408. uni.showModal({
  409. title: '公排商品不可与普通商品一起购买',
  410. showCancel: false
  411. });
  412. break;
  413. }
  414. }
  415. },
  416. // 提交订单
  417. submit() {
  418. let obj = this;
  419. // 判断是否为公排商品
  420. obj.seriationCode(obj.shopList);
  421. // 判断是否为积分商品
  422. // if (this.checkedPoints && this.shopList.length > 1) {
  423. // this.$api.msg('积分商品只可单件购买');
  424. // return false;
  425. // }
  426. if (obj.tabCurrentIndex === 1) {
  427. if (!obj.pickUpInfo.real_name) {
  428. obj.$api.msg('请填写用户名');
  429. return false;
  430. }
  431. if (!obj.pickUpInfo.phone) {
  432. obj.$api.msg('请填写手机号');
  433. return false;
  434. }
  435. obj.addressData.real_name = obj.pickUpInfo.real_name;
  436. obj.addressData.phone = obj.pickUpInfo.phone;
  437. }
  438. let url = '/pages/money/pay?key=' + obj.orderKey + '&goodsType=' + obj.goodsType;
  439. if(obj.is_consumer == 1) {
  440. url += '&consumer=1'
  441. }
  442. if (obj.pinkid) {
  443. url += '&pinkid=' + obj.pinkid;
  444. }
  445. uni.navigateTo({
  446. url
  447. });
  448. }
  449. }
  450. };
  451. </script>
  452. <style lang="scss">
  453. page {
  454. background: $page-color-base;
  455. padding-bottom: 100rpx;
  456. }
  457. .navbar {
  458. display: flex;
  459. height: 80rpx;
  460. padding: 0 5px;
  461. background: #fff;
  462. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
  463. position: relative;
  464. z-index: 10;
  465. .nav-item {
  466. flex: 1;
  467. display: flex;
  468. justify-content: center;
  469. align-items: center;
  470. height: 100%;
  471. font-size: $font-lg + 4rpx;
  472. color: $font-color-dark;
  473. position: relative;
  474. &.current {
  475. color: $base-color;
  476. &:after {
  477. content: '';
  478. position: absolute;
  479. left: 50%;
  480. bottom: 0;
  481. transform: translateX(-50%);
  482. width: 140rpx;
  483. height: 0;
  484. border-bottom: 2px solid $base-color;
  485. }
  486. }
  487. }
  488. }
  489. .address-section {
  490. padding: 30rpx 0;
  491. background: #fff;
  492. position: relative;
  493. border-top: 1px solid $border-color-light;
  494. .order-content {
  495. min-height: 100rpx;
  496. display: flex;
  497. align-items: center;
  498. .addAddress {
  499. text-align: center;
  500. width: 100%;
  501. display: flex;
  502. justify-content: center;
  503. align-items: center;
  504. line-height: 1;
  505. .iconaddition {
  506. font-size: 55rpx;
  507. border-radius: 100rpx;
  508. margin-right: 20rpx;
  509. }
  510. }
  511. }
  512. .iconlocation {
  513. flex-shrink: 0;
  514. display: flex;
  515. align-items: center;
  516. justify-content: center;
  517. width: 90rpx;
  518. color: #888;
  519. font-size: 44rpx;
  520. }
  521. .cen {
  522. display: flex;
  523. flex-direction: column;
  524. flex: 1;
  525. font-size: 28rpx;
  526. color: $font-color-dark;
  527. }
  528. .name {
  529. font-size: 34rpx;
  530. margin-right: 24rpx;
  531. }
  532. .address {
  533. margin-top: 16rpx;
  534. margin-right: 20rpx;
  535. color: $font-color-light;
  536. }
  537. .icon-you {
  538. font-size: 32rpx;
  539. color: $font-color-light;
  540. margin-right: 30rpx;
  541. }
  542. .a-bg {
  543. position: absolute;
  544. left: 0;
  545. bottom: 0;
  546. display: block;
  547. width: 100%;
  548. height: 5rpx;
  549. }
  550. }
  551. .goods-section {
  552. margin-top: 20rpx;
  553. background: #fff;
  554. padding-bottom: 1px;
  555. .g-header {
  556. display: flex;
  557. align-items: center;
  558. height: 84rpx;
  559. padding: 0 30rpx;
  560. position: relative;
  561. }
  562. .logo {
  563. display: block;
  564. width: 50rpx;
  565. height: 50rpx;
  566. border-radius: 100px;
  567. }
  568. .name {
  569. font-size: 30rpx;
  570. color: $font-color-base;
  571. margin-left: 24rpx;
  572. }
  573. .g-item {
  574. display: flex;
  575. padding: 20rpx 30rpx;
  576. image {
  577. flex-shrink: 0;
  578. display: block;
  579. width: 140rpx;
  580. height: 140rpx;
  581. border-radius: 4rpx;
  582. }
  583. .right {
  584. flex: 1;
  585. padding-left: 24rpx;
  586. overflow: hidden;
  587. }
  588. .title {
  589. font-size: 30rpx;
  590. color: $font-color-dark;
  591. }
  592. .spec {
  593. font-size: 26rpx;
  594. color: $font-color-light;
  595. }
  596. .price-box {
  597. display: flex;
  598. align-items: center;
  599. font-size: 32rpx;
  600. color: $font-color-dark;
  601. padding-top: 10rpx;
  602. .price {
  603. margin-bottom: 4rpx;
  604. color: $color-red;
  605. }
  606. .number {
  607. font-size: 26rpx;
  608. color: $font-color-base;
  609. margin-left: 20rpx;
  610. }
  611. }
  612. .step-box {
  613. position: relative;
  614. }
  615. }
  616. }
  617. .yt-list {
  618. margin-top: 16rpx;
  619. background: #fff;
  620. }
  621. .yt-list-cell {
  622. display: flex;
  623. align-items: center;
  624. padding: 10rpx 30rpx 10rpx 40rpx;
  625. line-height: 70rpx;
  626. position: relative;
  627. &.cell-hover {
  628. background: #fafafa;
  629. }
  630. &.b-b:after {
  631. left: 30rpx;
  632. }
  633. .cell-icon {
  634. height: 32rpx;
  635. width: 32rpx;
  636. font-size: 22rpx;
  637. color: #fff;
  638. text-align: center;
  639. line-height: 32rpx;
  640. background: #f85e52;
  641. border-radius: 4rpx;
  642. margin-right: 12rpx;
  643. &.hb {
  644. background: #ffaa0e;
  645. }
  646. &.lpk {
  647. background: #3ab54a;
  648. }
  649. }
  650. .cell-more {
  651. align-self: center;
  652. font-size: 24rpx;
  653. color: $font-color-light;
  654. margin-left: 8rpx;
  655. margin-right: -10rpx;
  656. }
  657. .cell-tit {
  658. flex: 1;
  659. font-size: 26rpx;
  660. color: $font-color-light;
  661. margin-right: 10rpx;
  662. }
  663. .cell-tip {
  664. font-size: 26rpx;
  665. color: $font-color-dark;
  666. &.disabled {
  667. color: $font-color-light;
  668. }
  669. &.active {
  670. color: $base-color;
  671. }
  672. &.red {
  673. color: $base-color;
  674. }
  675. }
  676. .cell-tip-1 {
  677. width: 28rpx;
  678. height: 28rpx;
  679. margin-right: 10rpx;
  680. }
  681. &.desc-cell {
  682. .cell-tit {
  683. max-width: 90rpx;
  684. }
  685. }
  686. .desc {
  687. flex: 1;
  688. text-align: right;
  689. font-size: $font-base;
  690. color: $font-color-dark;
  691. }
  692. }
  693. /* 支付列表 */
  694. .pay-list {
  695. padding-left: 40rpx;
  696. margin-top: 16rpx;
  697. background: #fff;
  698. .pay-item {
  699. display: flex;
  700. align-items: center;
  701. padding-right: 20rpx;
  702. line-height: 1;
  703. height: 110rpx;
  704. position: relative;
  705. }
  706. .icon-weixinzhifu {
  707. width: 80rpx;
  708. font-size: 40rpx;
  709. color: #6bcc03;
  710. }
  711. .icon-alipay {
  712. width: 80rpx;
  713. font-size: 40rpx;
  714. color: #06b4fd;
  715. }
  716. .icon-xuanzhong2 {
  717. display: flex;
  718. align-items: center;
  719. justify-content: center;
  720. width: 60rpx;
  721. height: 60rpx;
  722. font-size: 40rpx;
  723. color: $base-color;
  724. }
  725. .tit {
  726. font-size: 32rpx;
  727. color: $font-color-dark;
  728. flex: 1;
  729. }
  730. }
  731. .footer {
  732. position: fixed;
  733. left: 0;
  734. bottom: 0;
  735. z-index: 995;
  736. display: flex;
  737. align-items: center;
  738. width: 100%;
  739. height: 90rpx;
  740. justify-content: space-between;
  741. font-size: 30rpx;
  742. background-color: #fff;
  743. z-index: 998;
  744. color: $font-color-base;
  745. box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.1);
  746. .price-content {
  747. padding-left: 30rpx;
  748. }
  749. .price-tip {
  750. color: $font-color-base;
  751. margin-left: 8rpx;
  752. }
  753. .price-top-1 {
  754. margin-left: 8rpx;
  755. height: 32rpx;
  756. width: 32rpx;
  757. margin-right: 8rpx;
  758. }
  759. .price {
  760. font-size: 36rpx;
  761. color: $font-color-base;
  762. }
  763. .submit {
  764. display: flex;
  765. align-items: center;
  766. justify-content: center;
  767. width: 280rpx;
  768. height: 100%;
  769. color: #fff;
  770. font-size: 32rpx;
  771. background-color: $base-color;
  772. &.submitNo {
  773. background-color: $font-color-disabled;
  774. }
  775. }
  776. }
  777. /* 优惠券面板 */
  778. .mask {
  779. display: flex;
  780. align-items: flex-end;
  781. position: fixed;
  782. left: 0;
  783. top: var(--window-top);
  784. bottom: 0;
  785. width: 100%;
  786. background: rgba(0, 0, 0, 0);
  787. z-index: 9995;
  788. transition: 0.3s;
  789. .mask-content {
  790. width: 100%;
  791. min-height: 30vh;
  792. max-height: 70vh;
  793. background: #f3f3f3;
  794. transform: translateY(100%);
  795. transition: 0.3s;
  796. overflow-y: scroll;
  797. }
  798. &.none {
  799. display: none;
  800. }
  801. &.show {
  802. background: rgba(0, 0, 0, 0.4);
  803. .mask-content {
  804. transform: translateY(0);
  805. }
  806. }
  807. }
  808. /* 优惠券列表 */
  809. .coupon-item {
  810. display: flex;
  811. flex-direction: column;
  812. margin: 20rpx 24rpx;
  813. background: #fff;
  814. .con {
  815. display: flex;
  816. align-items: center;
  817. position: relative;
  818. height: 120rpx;
  819. padding: 0 30rpx;
  820. &:after {
  821. position: absolute;
  822. left: 0;
  823. bottom: 0;
  824. content: '';
  825. width: 100%;
  826. height: 0;
  827. border-bottom: 1px dashed #f3f3f3;
  828. transform: scaleY(50%);
  829. }
  830. }
  831. .left {
  832. display: flex;
  833. flex-direction: column;
  834. justify-content: center;
  835. flex: 1;
  836. overflow: hidden;
  837. height: 100rpx;
  838. }
  839. .title {
  840. font-size: 32rpx;
  841. color: $font-color-dark;
  842. margin-bottom: 10rpx;
  843. }
  844. .time {
  845. font-size: 24rpx;
  846. color: $font-color-light;
  847. }
  848. .right {
  849. display: flex;
  850. flex-direction: column;
  851. justify-content: center;
  852. align-items: center;
  853. font-size: 26rpx;
  854. color: $font-color-base;
  855. height: 100rpx;
  856. }
  857. .price {
  858. font-size: 44rpx;
  859. color: $base-color;
  860. &:before {
  861. content: '¥';
  862. font-size: 34rpx;
  863. }
  864. }
  865. .tips {
  866. font-size: 24rpx;
  867. color: $font-color-light;
  868. line-height: 60rpx;
  869. padding-left: 30rpx;
  870. }
  871. .circle {
  872. position: absolute;
  873. left: -6rpx;
  874. bottom: -10rpx;
  875. z-index: 10;
  876. width: 20rpx;
  877. height: 20rpx;
  878. background: #f3f3f3;
  879. border-radius: 100px;
  880. &.r {
  881. left: auto;
  882. right: -6rpx;
  883. }
  884. }
  885. }
  886. </style>