景徳镇旅游微信小程序
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.

363 lines
6.9 KiB

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