createOrder.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  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="shopList[0].productInfo.max_use_integral > 0">
  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+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi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kUa1IvF7JcribPbxZnt9BYIeBZm0ap1BO2yHLMOIxjH111chmDocXg9XzZFR4fD74e5cA9GtQEulbLGbfaNMvv4+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. if(obj.tabCurrentIndex === 0) {
  439. if(!obj.addressData.real_name) {
  440. obj.$api.msg('请选择收货地址');
  441. return false;
  442. }
  443. }
  444. let url = '/pages/money/pay?key=' + obj.orderKey + '&goodsType=' + obj.goodsType;
  445. if(obj.is_consumer == 1) {
  446. url += '&consumer=1'
  447. }
  448. if (obj.pinkid) {
  449. url += '&pinkid=' + obj.pinkid;
  450. }
  451. uni.navigateTo({
  452. url
  453. });
  454. }
  455. }
  456. };
  457. </script>
  458. <style lang="scss">
  459. page {
  460. background: $page-color-base;
  461. padding-bottom: 100rpx;
  462. }
  463. .navbar {
  464. display: flex;
  465. height: 80rpx;
  466. padding: 0 5px;
  467. background: #fff;
  468. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
  469. position: relative;
  470. z-index: 10;
  471. .nav-item {
  472. flex: 1;
  473. display: flex;
  474. justify-content: center;
  475. align-items: center;
  476. height: 100%;
  477. font-size: $font-lg + 4rpx;
  478. color: $font-color-dark;
  479. position: relative;
  480. &.current {
  481. color: $base-color;
  482. &:after {
  483. content: '';
  484. position: absolute;
  485. left: 50%;
  486. bottom: 0;
  487. transform: translateX(-50%);
  488. width: 140rpx;
  489. height: 0;
  490. border-bottom: 2px solid $base-color;
  491. }
  492. }
  493. }
  494. }
  495. .address-section {
  496. padding: 30rpx 0;
  497. background: #fff;
  498. position: relative;
  499. border-top: 1px solid $border-color-light;
  500. .order-content {
  501. min-height: 100rpx;
  502. display: flex;
  503. align-items: center;
  504. .addAddress {
  505. text-align: center;
  506. width: 100%;
  507. display: flex;
  508. justify-content: center;
  509. align-items: center;
  510. line-height: 1;
  511. .iconaddition {
  512. font-size: 55rpx;
  513. border-radius: 100rpx;
  514. margin-right: 20rpx;
  515. }
  516. }
  517. }
  518. .iconlocation {
  519. flex-shrink: 0;
  520. display: flex;
  521. align-items: center;
  522. justify-content: center;
  523. width: 90rpx;
  524. color: #888;
  525. font-size: 44rpx;
  526. }
  527. .cen {
  528. display: flex;
  529. flex-direction: column;
  530. flex: 1;
  531. font-size: 28rpx;
  532. color: $font-color-dark;
  533. }
  534. .name {
  535. font-size: 34rpx;
  536. margin-right: 24rpx;
  537. }
  538. .address {
  539. margin-top: 16rpx;
  540. margin-right: 20rpx;
  541. color: $font-color-light;
  542. }
  543. .icon-you {
  544. font-size: 32rpx;
  545. color: $font-color-light;
  546. margin-right: 30rpx;
  547. }
  548. .a-bg {
  549. position: absolute;
  550. left: 0;
  551. bottom: 0;
  552. display: block;
  553. width: 100%;
  554. height: 5rpx;
  555. }
  556. }
  557. .goods-section {
  558. margin-top: 20rpx;
  559. background: #fff;
  560. padding-bottom: 1px;
  561. .g-header {
  562. display: flex;
  563. align-items: center;
  564. height: 84rpx;
  565. padding: 0 30rpx;
  566. position: relative;
  567. }
  568. .logo {
  569. display: block;
  570. width: 50rpx;
  571. height: 50rpx;
  572. border-radius: 100px;
  573. }
  574. .name {
  575. font-size: 30rpx;
  576. color: $font-color-base;
  577. margin-left: 24rpx;
  578. }
  579. .g-item {
  580. display: flex;
  581. padding: 20rpx 30rpx;
  582. image {
  583. flex-shrink: 0;
  584. display: block;
  585. width: 140rpx;
  586. height: 140rpx;
  587. border-radius: 4rpx;
  588. }
  589. .right {
  590. flex: 1;
  591. padding-left: 24rpx;
  592. overflow: hidden;
  593. }
  594. .title {
  595. font-size: 30rpx;
  596. color: $font-color-dark;
  597. }
  598. .spec {
  599. font-size: 26rpx;
  600. color: $font-color-light;
  601. }
  602. .price-box {
  603. display: flex;
  604. align-items: center;
  605. font-size: 32rpx;
  606. color: $font-color-dark;
  607. padding-top: 10rpx;
  608. .price {
  609. margin-bottom: 4rpx;
  610. color: $color-red;
  611. }
  612. .number {
  613. font-size: 26rpx;
  614. color: $font-color-base;
  615. margin-left: 20rpx;
  616. }
  617. }
  618. .step-box {
  619. position: relative;
  620. }
  621. }
  622. }
  623. .yt-list {
  624. margin-top: 16rpx;
  625. background: #fff;
  626. }
  627. .yt-list-cell {
  628. display: flex;
  629. align-items: center;
  630. padding: 10rpx 30rpx 10rpx 40rpx;
  631. line-height: 70rpx;
  632. position: relative;
  633. &.cell-hover {
  634. background: #fafafa;
  635. }
  636. &.b-b:after {
  637. left: 30rpx;
  638. }
  639. .cell-icon {
  640. height: 32rpx;
  641. width: 32rpx;
  642. font-size: 22rpx;
  643. color: #fff;
  644. text-align: center;
  645. line-height: 32rpx;
  646. background: #f85e52;
  647. border-radius: 4rpx;
  648. margin-right: 12rpx;
  649. &.hb {
  650. background: #ffaa0e;
  651. }
  652. &.lpk {
  653. background: #3ab54a;
  654. }
  655. }
  656. .cell-more {
  657. align-self: center;
  658. font-size: 24rpx;
  659. color: $font-color-light;
  660. margin-left: 8rpx;
  661. margin-right: -10rpx;
  662. }
  663. .cell-tit {
  664. flex: 1;
  665. font-size: 26rpx;
  666. color: $font-color-light;
  667. margin-right: 10rpx;
  668. }
  669. .cell-tip {
  670. font-size: 26rpx;
  671. color: $font-color-dark;
  672. &.disabled {
  673. color: $font-color-light;
  674. }
  675. &.active {
  676. color: $base-color;
  677. }
  678. &.red {
  679. color: $base-color;
  680. }
  681. }
  682. .cell-tip-1 {
  683. width: 28rpx;
  684. height: 28rpx;
  685. margin-right: 10rpx;
  686. }
  687. &.desc-cell {
  688. .cell-tit {
  689. max-width: 90rpx;
  690. }
  691. }
  692. .desc {
  693. flex: 1;
  694. text-align: right;
  695. font-size: $font-base;
  696. color: $font-color-dark;
  697. }
  698. }
  699. /* 支付列表 */
  700. .pay-list {
  701. padding-left: 40rpx;
  702. margin-top: 16rpx;
  703. background: #fff;
  704. .pay-item {
  705. display: flex;
  706. align-items: center;
  707. padding-right: 20rpx;
  708. line-height: 1;
  709. height: 110rpx;
  710. position: relative;
  711. }
  712. .icon-weixinzhifu {
  713. width: 80rpx;
  714. font-size: 40rpx;
  715. color: #6bcc03;
  716. }
  717. .icon-alipay {
  718. width: 80rpx;
  719. font-size: 40rpx;
  720. color: #06b4fd;
  721. }
  722. .icon-xuanzhong2 {
  723. display: flex;
  724. align-items: center;
  725. justify-content: center;
  726. width: 60rpx;
  727. height: 60rpx;
  728. font-size: 40rpx;
  729. color: $base-color;
  730. }
  731. .tit {
  732. font-size: 32rpx;
  733. color: $font-color-dark;
  734. flex: 1;
  735. }
  736. }
  737. .footer {
  738. position: fixed;
  739. left: 0;
  740. bottom: 0;
  741. z-index: 995;
  742. display: flex;
  743. align-items: center;
  744. width: 100%;
  745. height: 90rpx;
  746. justify-content: space-between;
  747. font-size: 30rpx;
  748. background-color: #fff;
  749. z-index: 998;
  750. color: $font-color-base;
  751. box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.1);
  752. .price-content {
  753. padding-left: 30rpx;
  754. }
  755. .price-tip {
  756. color: $font-color-base;
  757. margin-left: 8rpx;
  758. }
  759. .price-top-1 {
  760. margin-left: 8rpx;
  761. height: 32rpx;
  762. width: 32rpx;
  763. margin-right: 8rpx;
  764. }
  765. .price {
  766. font-size: 36rpx;
  767. color: $font-color-base;
  768. }
  769. .submit {
  770. display: flex;
  771. align-items: center;
  772. justify-content: center;
  773. width: 280rpx;
  774. height: 100%;
  775. color: #fff;
  776. font-size: 32rpx;
  777. background-color: $base-color;
  778. &.submitNo {
  779. background-color: $font-color-disabled;
  780. }
  781. }
  782. }
  783. /* 优惠券面板 */
  784. .mask {
  785. display: flex;
  786. align-items: flex-end;
  787. position: fixed;
  788. left: 0;
  789. top: var(--window-top);
  790. bottom: 0;
  791. width: 100%;
  792. background: rgba(0, 0, 0, 0);
  793. z-index: 9995;
  794. transition: 0.3s;
  795. .mask-content {
  796. width: 100%;
  797. min-height: 30vh;
  798. max-height: 70vh;
  799. background: #f3f3f3;
  800. transform: translateY(100%);
  801. transition: 0.3s;
  802. overflow-y: scroll;
  803. }
  804. &.none {
  805. display: none;
  806. }
  807. &.show {
  808. background: rgba(0, 0, 0, 0.4);
  809. .mask-content {
  810. transform: translateY(0);
  811. }
  812. }
  813. }
  814. /* 优惠券列表 */
  815. .coupon-item {
  816. display: flex;
  817. flex-direction: column;
  818. margin: 20rpx 24rpx;
  819. background: #fff;
  820. .con {
  821. display: flex;
  822. align-items: center;
  823. position: relative;
  824. height: 120rpx;
  825. padding: 0 30rpx;
  826. &:after {
  827. position: absolute;
  828. left: 0;
  829. bottom: 0;
  830. content: '';
  831. width: 100%;
  832. height: 0;
  833. border-bottom: 1px dashed #f3f3f3;
  834. transform: scaleY(50%);
  835. }
  836. }
  837. .left {
  838. display: flex;
  839. flex-direction: column;
  840. justify-content: center;
  841. flex: 1;
  842. overflow: hidden;
  843. height: 100rpx;
  844. }
  845. .title {
  846. font-size: 32rpx;
  847. color: $font-color-dark;
  848. margin-bottom: 10rpx;
  849. }
  850. .time {
  851. font-size: 24rpx;
  852. color: $font-color-light;
  853. }
  854. .right {
  855. display: flex;
  856. flex-direction: column;
  857. justify-content: center;
  858. align-items: center;
  859. font-size: 26rpx;
  860. color: $font-color-base;
  861. height: 100rpx;
  862. }
  863. .price {
  864. font-size: 44rpx;
  865. color: $base-color;
  866. &:before {
  867. content: '¥';
  868. font-size: 34rpx;
  869. }
  870. }
  871. .tips {
  872. font-size: 24rpx;
  873. color: $font-color-light;
  874. line-height: 60rpx;
  875. padding-left: 30rpx;
  876. }
  877. .circle {
  878. position: absolute;
  879. left: -6rpx;
  880. bottom: -10rpx;
  881. z-index: 10;
  882. width: 20rpx;
  883. height: 20rpx;
  884. background: #f3f3f3;
  885. border-radius: 100px;
  886. &.r {
  887. left: auto;
  888. right: -6rpx;
  889. }
  890. }
  891. }
  892. </style>