海南旅游项目 前端仓库
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.

227 lines
7.6 KiB

  1. <template>
  2. <view v-if="$isRight(goods_details)">
  3. <view class="lf-bg-white lf-p-t-30 lf-p-b-30 lf-p-l-32 lf-p-r-32">
  4. <view class="lf-row-between">
  5. <image :src="goods_details.product.picture" mode="aspectFill" style="width: 240rpx; height: 240rpx;border-radius: 20rpx;"></image>
  6. <view class="flex-sub padding-left-sm">
  7. <view class="bref-box lf-font-32 lf-color-333 lf-line-2" style="height: 88rpx;line-height: 44rpx;">
  8. {{goods_details.product.title}}
  9. </view>
  10. <view class="flex lf-m-t-25 align-center text-center">
  11. <text class="block lf-color-gray lf-font-24" style="line-height: 40rpx;">数量</text>
  12. <text class="lf-m-l-10 lf-color-gray lf-font-24">x {{goods_details.num}}</text>
  13. </view>
  14. <view class="flex align-center text-center lf-m-t-25">
  15. <lf-price :price="goods_details.price" />
  16. <view class="lf-m-l-20 lf-line-through lf-color-gray">
  17. {{goods_details.original_price}}
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <self-line/>
  24. <view class="bg-white">
  25. <view class="cu-bar padding-lr">
  26. <text class="lf-color-555 lf-font-28">优惠</text>
  27. <view v-if="goods_details.coupon != ''">
  28. <text class="lf-color-price lf-font-28 lf-m-l-10" v-for="(item,index) of goods_details.coupon">{{item.tag}}</text>
  29. </view>
  30. <view v-else>
  31. <text class="lf-color-price lf-font-28 lf-m-l-10">暂无优惠</text>
  32. </view>
  33. </view>
  34. </view>
  35. <self-line/>
  36. <view class="bg-white" v-if="enter_type!=1">
  37. <view class="cu-bar padding-lr solid-bottom">
  38. <text class="lf-color-555 lf-font-28">联系人</text>
  39. <input type="text" v-model="contact" class="lf-color-999 lf-font-28 lf-text-right" placeholder="请输入联系人" />
  40. </view>
  41. <view class="cu-bar padding-lr">
  42. <text class="lf-color-555 lf-font-28">联系方式</text>
  43. <input type="text" v-model="phone" class="lf-color-999 lf-font-28 lf-text-right" placeholder="请输入联系电话" maxlength="11" />
  44. </view>
  45. </view>
  46. <self-line/>
  47. <view class="bg-white" v-if="enter_type!=1">
  48. <view class="lf-p-t-30 lf-p-l-32 lf-p-b-36">
  49. <view class="lf-font-28 lf-color-555">支付方式</view>
  50. </view>
  51. <view class="lf-p-r-32 lf-p-l-32">
  52. <button class="cu-btn bg-white margin-self" :class="pay_type==0?'border-green':'border'" @tap="payStatus(0)">
  53. <text class="lf-iconfont lf-icon-weixin text-green lf-font-44 lf-m-r-23"></text>
  54. <text class="lf-font-32" :class="pay_type==0?'text-green':'lf-color-333'">微信支付</text>
  55. <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==0" style="position: absolute;right: 22rpx;"></text>
  56. </button>
  57. </view>
  58. <view class="lf-p-r-32 lf-p-l-32 lf-m-t-30">
  59. <button class="cu-btn bg-white margin-self" :class="pay_type==1?'border-green':'border'" @tap="payStatus(1)">
  60. <text class="lf-font-32" :class="pay_type==1?'text-green':'lf-color-333'">定金支付</text>
  61. <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==1" style="position: absolute;right: 22rpx;"></text>
  62. </button>
  63. </view>
  64. <view class="lf-p-r-32 lf-p-l-32 lf-m-t-30">
  65. <button class="cu-btn bg-white margin-self" :class="pay_type==2?'border-green':'border'" @tap="payStatus(2)">
  66. <text class="lf-font-32" :class="pay_type==2?'text-green':'lf-color-333'">首款支付</text>
  67. <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==2" style="position: absolute;right: 22rpx;"></text>
  68. </button>
  69. </view>
  70. <view class="lf-p-r-32 lf-p-l-32 lf-m-t-30">
  71. <button class="cu-btn bg-white margin-self" :class="pay_type==3?'border-green':'border'" @tap="payStatus(3)">
  72. <text class="lf-font-32" :class="pay_type==3?'text-green':'lf-color-333'">线下支付</text>
  73. <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==3" style="position: absolute;right: 22rpx;"></text>
  74. </button>
  75. </view>
  76. </view>
  77. <view class="btn-bottom solid-top1">
  78. <view class="padding-lr lf-p-t-10 lf-p-b-10 bg-white flex justify-between align-center shadow">
  79. <view class="flex align-center">
  80. <text class="lf-font-24 lf-font-555">应付款</text>
  81. <lf-price :price="goods_details.final_price" />
  82. </view>
  83. <button class="btn" @tap="submit">
  84. <text class="lf-font-32 text-white" v-if="btn_type == 1">下单付款</text>
  85. <text class="lf-font-32 text-white" v-else>支付尾款</text>
  86. </button>
  87. </view>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. export default {
  93. data() {
  94. return {
  95. goods_id: 0,
  96. goods_details: {},
  97. contact: '',
  98. phone: '',
  99. pay_type: 0,
  100. btn_type: 1,
  101. ifPay: true,
  102. order_id: 0,
  103. enter_type: 0
  104. }
  105. },
  106. onLoad(e) {
  107. this.goods_id = e.goods_id;
  108. this.btn_type = e.btn_type;
  109. this.order_id = e.order_id;
  110. this.enter_type = e.enter_type;
  111. if(this.goods_id) {
  112. this.getGoodsData(this.pay_type);
  113. }
  114. if(this.order_id && this.enter_type == 1) {
  115. this.payOnce();
  116. }
  117. },
  118. methods: {
  119. payStatus(type) {
  120. if(type == this.pay_type) {
  121. this.pay_type = type;
  122. return
  123. }else {
  124. this.pay_type = type;
  125. this.getGoodsData(type);
  126. }
  127. },
  128. getGoodsData(type){
  129. this.$http(this.API.API_CONFIRMDETAILS,{id: this.goods_id,num: 1,pay_type: type}).then(res => {
  130. this.goods_details = res.data;
  131. console.log(res)
  132. })
  133. },
  134. submit() {
  135. if(!this.contact) {
  136. this.$msg('请输入联系人!');
  137. return;
  138. }
  139. if(!this.phone) {
  140. this.$msg('请输入联系电话!');
  141. return;
  142. }
  143. if(!this.ifPay) return;
  144. this.ifPay = false;
  145. this.$http(this.API.API_CREATEORDER,{id: this.goods_id,num: 1,pay_type: this.pay_type,name:this.contact,mobile:this.phone}).then(res => {
  146. this.order_id = res.data.id
  147. console.log(res)
  148. if(this.pay_type == 3) {
  149. this.ifPay = true
  150. this.$url('/pages/payState/paystate?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  151. }else {
  152. uni.requestPayment({
  153. orderInfo: res.data.order_num,
  154. timeStamp: res.data.timeStamp,
  155. nonceStr: res.data.nonceStr,
  156. package: res.data.package,
  157. signType: res.data.signType,
  158. paySign: res.data.paySign,
  159. success: (res) => {
  160. this.ifPay = true
  161. this.$url('/pages/payState/paystate?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  162. },
  163. fail: (err) => {
  164. this.ifPay = true
  165. this.$url('/pages/payState/paystate?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  166. },
  167. })
  168. }
  169. }).catch(err => {
  170. this.ifPay = true
  171. })
  172. },
  173. payOnce() {
  174. this.$http(this.API.API_ORDERPAY,{id: this.order_id}).then(res => {
  175. uni.requestPayment({
  176. orderInfo: res.data.order_num,
  177. timeStamp: res.data.timeStamp,
  178. nonceStr: res.data.nonceStr,
  179. package: res.data.package,
  180. signType: res.data.signType,
  181. paySign: res.data.paySign,
  182. success: (res) => {
  183. this.$url('/pages/payState/paystate?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  184. },
  185. fail: (err) => {
  186. this.$url('/pages/payState/paystate?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  187. },
  188. })
  189. }).catch(err => {})
  190. }
  191. }
  192. }
  193. </script>
  194. <style>
  195. .btn{
  196. margin: 0;
  197. padding: 0;
  198. width: 212rpx;
  199. height: 82rpx;
  200. background-color: #1998FE;
  201. color: #FFFFFF;
  202. line-height: 80rpx;
  203. font-size: 32rpx;
  204. border-radius: 41rpx;
  205. }
  206. .bref-box {
  207. text-overflow: -o-ellipsis-lastline;
  208. overflow: hidden;
  209. text-overflow: ellipsis;
  210. display: -webkit-box;
  211. -webkit-line-clamp: 2;
  212. -webkit-box-orient: vertical;
  213. }
  214. </style>