createOrder.vue 26 KB

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