瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

494 lines
10 KiB

11 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
9 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
9 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
9 months ago
10 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
9 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
11 months ago
10 months ago
11 months ago
9 months ago
9 months ago
9 months ago
11 months ago
9 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
  1. <template>
  2. <uv-popup ref="popup"
  3. :round="30"
  4. bgColor="#f7f7f7">
  5. <view class="content">
  6. <!-- 配送方式选择 -->
  7. <view class="delivery-method">
  8. <view class="title">配送方式</view>
  9. <view class="options">
  10. <view
  11. :class="['option', { active: deliveryMethod === '0' }]"
  12. @click="selectDeliveryMethod('0')"
  13. >
  14. <view class="icon">🚚</view>
  15. <view class="text">外卖配送</view>
  16. </view>
  17. <view
  18. :class="['option', { active: deliveryMethod === '1' }]"
  19. @click="selectDeliveryMethod('1')"
  20. >
  21. <view class="icon">🏪</view>
  22. <view class="text">到店自提</view>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 地址仅外卖显示 -->
  27. <view class="address"
  28. @click="openAddress"
  29. v-if="deliveryMethod === '0'">
  30. <image src="../../static/address/selectIcon.png" mode=""></image>
  31. <view class="">
  32. {{ address.name }}
  33. </view>
  34. <view class="">
  35. {{ address.addressDetail }}
  36. </view>
  37. <view class="icon">
  38. <uv-icon
  39. size="30rpx"
  40. name="arrow-right"></uv-icon>
  41. </view>
  42. </view>
  43. <!-- 店铺地址仅到店自提显示 -->
  44. <view class="store-address" v-if="deliveryMethod == '1' && detail.shop && detail.shop.address">
  45. <view>
  46. <addressSpot
  47. :address="detail.shop.address"
  48. :latitude="detail.shop.latitude"
  49. :longitude="detail.shop.longitude"
  50. />
  51. </view>
  52. </view>
  53. <!-- 商品信息和数量 -->
  54. <view class="submit-info">
  55. <view class="title">
  56. {{ detail.name }}
  57. </view>
  58. <view class="box">
  59. <image
  60. class="image"
  61. :src="detail.image && detail.image.split(',')[0]"
  62. mode=""></image>
  63. <view class="info">
  64. <view class="price"
  65. v-if="isProductPrice(detail)">
  66. 价格<text>{{ detail.price }}</text>
  67. </view>
  68. <!-- <view class="unit">
  69. 请选择规格
  70. </view> -->
  71. <view class="favorable"
  72. v-if="isProductPoint(detail)">
  73. <view class="t">
  74. 积分兑换
  75. </view>
  76. <view class="p">
  77. {{ detail.points }}
  78. </view>
  79. </view>
  80. <view class="">
  81. <uv-number-box v-model="num"></uv-number-box>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. <!-- 规格 -->
  87. <!-- <view class="submit-unit">
  88. <view class="title">
  89. 规格选择
  90. </view>
  91. <view class="list">
  92. <view :class="{act : unitIndex == index}"
  93. v-for="(item, index) in detail.hotelGoodsSkuList"
  94. @click="selectUnit(item, index)"
  95. :key="index">
  96. {{ item.title }}
  97. </view>
  98. </view>
  99. </view> -->
  100. <!-- 费用明细 -->
  101. <view class="expense-detail">
  102. <view class="title">
  103. 费用明细
  104. </view>
  105. <view class="detail"
  106. v-if="isProductPoint(detail)">
  107. 积分{{ detail.points }}
  108. </view>
  109. <view class="detail"
  110. v-if="isProductPrice(detail)">
  111. 金额{{ detail.price }}
  112. </view>
  113. </view>
  114. <!-- 提交按钮 -->
  115. <view class="submit-btn">
  116. <view class="r"
  117. v-if="isProductPoint(detail)"
  118. @click="exchange">
  119. 立即兑换
  120. </view>
  121. <view class="r"
  122. v-if="isProductPrice(detail)"
  123. @click="orderPay">
  124. 立即购买
  125. </view>
  126. </view>
  127. </view>
  128. <uv-popup ref="addressPopup" :round="30">
  129. <addressList
  130. ref="addressList"
  131. height="60vh"
  132. @select="selectAddress"
  133. />
  134. </uv-popup>
  135. </uv-popup>
  136. </template>
  137. <script>
  138. import addressList from '../address/addressList.vue'
  139. import productMixins from '@/mixins/product.js'
  140. export default {
  141. mixins : [productMixins],
  142. components : {
  143. addressList,
  144. },
  145. props : {
  146. submiitTitle : {
  147. default : '立即购买',
  148. type : String,
  149. },
  150. detail : {
  151. default : {}
  152. }
  153. },
  154. data() {
  155. return {
  156. unitIndex : 0,
  157. address : {
  158. name : '请选择联系人',
  159. addressDetail : '',
  160. },
  161. num : 1,
  162. unit : {},
  163. addressTotal : 0,
  164. deliveryMethod : '0',
  165. }
  166. },
  167. methods: {
  168. // 打开
  169. open(){
  170. this.$refs.popup.open('bottom')
  171. // if(!this.unit.id){
  172. // this.selectUnit(this.detail.hotelGoodsSkuList[0], 0)
  173. // }
  174. // 获取地址列表
  175. this.$refs.addressList.getAddressList().then(res => {
  176. this.addressTotal = res.total
  177. if(this.addressTotal != 0){
  178. this.address = res.records[0]
  179. }
  180. })
  181. },
  182. // 关闭
  183. close(){
  184. this.$refs.popup.close()
  185. },
  186. // 打开选择地址
  187. openAddress(){
  188. if (this.addressTotal == 0) {
  189. this.$refs.popup.close()
  190. return uni.navigateTo({
  191. url: '/pages_order/mine/address?type=back'
  192. })
  193. }
  194. this.$refs.addressPopup.open('bottom')
  195. },
  196. // 选择地址
  197. selectAddress(e){
  198. this.address = e
  199. this.$refs.addressPopup.close()
  200. },
  201. // 选择规格
  202. selectUnit(item, index){
  203. this.unit = item
  204. this.unitIndex = index
  205. },
  206. // 积分兑换
  207. exchange(){
  208. let data = {
  209. shopId : this.detail.id,//商品id
  210. num : this.num,
  211. deliveryMethod: this.deliveryMethod
  212. }
  213. // 外卖配送需要地址
  214. if (this.deliveryMethod === 'delivery') {
  215. if (!this.address.id) {
  216. return uni.showToast({
  217. title: '请选择收货地址',
  218. icon: 'none'
  219. })
  220. }
  221. data.addressId = this.address.id
  222. }
  223. this.$api('createPointsOrder', data, res => {
  224. if(res.code == 200){
  225. uni.redirectTo({
  226. url: '/pages_order/order/order'
  227. })
  228. }
  229. })
  230. },
  231. orderPay(){
  232. let data = {
  233. shopId : this.detail.id,//商品id
  234. // skuId : this.unit.id,//规格id
  235. // sku : this.unit.title,//规格
  236. num : this.num,
  237. deliveryMethod: this.deliveryMethod
  238. }
  239. // 外卖配送需要地址
  240. if (this.deliveryMethod == '0') {
  241. if (!this.address.id) {
  242. return uni.showToast({
  243. title: '请选择收货地址',
  244. icon: 'none'
  245. })
  246. }
  247. data.addressId = this.address.id
  248. }
  249. this.$api('createOrder', data, res => {
  250. if(res.code == 200){
  251. uni.requestPayment({
  252. provider: 'wxpay', // 服务提提供商
  253. timeStamp: res.result.timeStamp, // 时间戳
  254. nonceStr: res.result.nonceStr, // 随机字符串
  255. package: res.result.packageValue,
  256. signType: res.result.signType, // 签名算法
  257. paySign: res.result.paySign, // 签名
  258. success: function (res) {
  259. console.log('支付成功',res);
  260. uni.redirectTo({
  261. url: '/pages_order/order/order'
  262. })
  263. },
  264. fail: function (err) {
  265. console.log('支付失败',err);
  266. uni.showToast({
  267. icon:'none',
  268. title:"支付失败"
  269. })
  270. }
  271. });
  272. }
  273. })
  274. },
  275. selectDeliveryMethod(method){
  276. this.deliveryMethod = method
  277. },
  278. }
  279. }
  280. </script>
  281. <style scoped lang="scss">
  282. .content{
  283. max-height: 80vh;
  284. overflow: hidden;
  285. overflow-y: auto;
  286. .delivery-method{
  287. padding: 20rpx;
  288. background-color: #fff;
  289. .title{
  290. font-size: 30rpx;
  291. padding: 10rpx;
  292. font-weight: 600;
  293. }
  294. .options{
  295. display: flex;
  296. gap: 20rpx;
  297. .option{
  298. padding: 15rpx 30rpx;
  299. border: 2rpx solid #F3F3F3;
  300. border-radius: 10rpx;
  301. display: flex;
  302. align-items: center;
  303. justify-content: center;
  304. flex: 1;
  305. background-color: #F6F6F6;
  306. &.active{
  307. border-color: $uni-price-color;
  308. background-color: $uni-price-color;
  309. color: #fff;
  310. }
  311. .icon{
  312. margin-right: 10rpx;
  313. }
  314. .text{
  315. font-size: 28rpx;
  316. }
  317. }
  318. }
  319. }
  320. .address{
  321. display: flex;
  322. padding: 20rpx;
  323. background-color: #fff;
  324. image{
  325. width: 30rpx;
  326. height: 30rpx;
  327. margin: 20rpx;
  328. }
  329. view{
  330. margin: 20rpx;
  331. overflow:hidden; //超出的文本隐藏
  332. text-overflow:ellipsis; //溢出用省略号显示
  333. white-space:nowrap; //溢出不换行
  334. }
  335. .icon{
  336. margin-left: auto;
  337. }
  338. }
  339. .submit-info{
  340. background-color: #fff;
  341. padding: 30rpx;
  342. margin-top: 20rpx;
  343. .title{
  344. font-size: 30rpx;
  345. padding: 10rpx;
  346. font-weight: 600;
  347. }
  348. .box{
  349. display: flex;
  350. margin-top: 10rpx;
  351. .image{
  352. width: 200rpx;
  353. height: 200rpx;
  354. border-radius: 20rpx;
  355. margin-right: 20rpx;
  356. }
  357. .info{
  358. flex: 1;
  359. .unit{
  360. font-size: 24rpx;
  361. padding: 10rpx 20rpx;
  362. color: #717171;
  363. display: flex;
  364. align-items: center;
  365. }
  366. .price{
  367. color: $uni-price-color;
  368. font-size: 28rpx;
  369. padding: 10rpx 20rpx;
  370. text{
  371. font-size: 36rpx;
  372. font-weight: 900;
  373. }
  374. }
  375. .favorable{
  376. margin-left: 10rpx;
  377. display: flex;
  378. // background-image: url(/static/image/product/favorable.png);
  379. background-size: 100% 100%;
  380. width: fit-content;
  381. font-size: 22rpx;
  382. margin-top: 6rpx;
  383. margin-bottom: 6rpx;
  384. border-radius: 10rpx;
  385. overflow: hidden;
  386. background-color: #ff000011;
  387. .t{
  388. padding: 5rpx 10rpx;
  389. }
  390. .p{
  391. padding: 5rpx 10rpx;
  392. color: #fff;
  393. background-color: #F03F25;
  394. height: 100%;
  395. }
  396. }
  397. }
  398. }
  399. }
  400. .submit-unit{
  401. padding: 30rpx;
  402. background-color: #fff;
  403. .title{
  404. font-size: 28rpx;
  405. font-weight: 600;
  406. }
  407. .list{
  408. display: flex;
  409. flex-wrap: wrap;
  410. font-size: 22rpx;
  411. .act{
  412. color: $uni-price-color;
  413. border: 1px solid $uni-price-color;
  414. background-color: #F9E7DE;
  415. }
  416. view{
  417. border-radius: 15rpx;
  418. width: 320rpx;
  419. background-color: #F3F3F3;
  420. border: 1px solid #F3F3F3;
  421. margin: 10rpx;
  422. display: flex;
  423. justify-content: center;
  424. padding: 15rpx 0;
  425. }
  426. }
  427. }
  428. .expense-detail{
  429. padding: 30rpx;
  430. background-color: #fff;
  431. font-size: 28rpx;
  432. .title{
  433. font-weight: 600;
  434. }
  435. .detail{
  436. background-color: #F6F6F6;
  437. color: #717171;
  438. margin: 10rpx 0;
  439. padding: 10rpx 20rpx;
  440. }
  441. }
  442. .submit-btn{
  443. width: 600rpx;
  444. height: 80rpx;
  445. color: #fff;
  446. border-radius: 40rpx;
  447. font-size: 28rpx;
  448. margin: 20rpx auto;
  449. display: flex;
  450. justify-content: center;
  451. align-items: center;
  452. border: 1rpx solid $uni-price-color;
  453. overflow: hidden;
  454. .l{
  455. flex: 1;
  456. display: flex;
  457. justify-content: center;
  458. align-items: center;
  459. color: $uni-price-color;
  460. }
  461. .r{
  462. background: $uni-price-color;
  463. flex: 1;
  464. height: 100%;
  465. display: flex;
  466. justify-content: center;
  467. align-items: center;
  468. }
  469. }
  470. }
  471. </style>