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

415 lines
8.2 KiB

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