瑶都万能墙
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.

496 lines
10 KiB

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