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

402 lines
7.8 KiB

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