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

408 lines
8.0 KiB

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