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

263 lines
8.5 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  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.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.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" v-if="goods_details.deposit != '0.00'">
  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" v-if="goods_details.earnest != '0.00'" :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 class="lf-p-r-32 lf-p-l-32 lf-m-t-30">
  77. <button class="cu-btn bg-white margin-self" :class="pay_type==4?'border-green':'border'" @tap="payStatus(4)">
  78. <text class="lf-font-32" :class="pay_type==4?'text-green':'lf-color-333'">首款支付</text>
  79. <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==4" style="position: absolute;right: 22rpx;"></text>
  80. </button>
  81. </view> -->
  82. </view>
  83. <view class="btn-bottom solid-top1">
  84. <view class="padding-lr lf-p-t-10 lf-p-b-10 bg-white flex justify-between align-center shadow">
  85. <view class="flex align-center">
  86. <text class="lf-font-24 lf-font-555">应付款</text>
  87. <lf-price :price="goods_details.final_price" />
  88. </view>
  89. <button class="btn" @tap="submit">
  90. <text class="lf-font-32 text-white" v-if="btn_type == 1">下单付款</text>
  91. <text class="lf-font-32 text-white" v-else>支付尾款</text>
  92. </button>
  93. </view>
  94. </view>
  95. </view>
  96. </template>
  97. <script>
  98. export default {
  99. data() {
  100. return {
  101. goods_id: 0,
  102. goods_details: {},
  103. contact: '',
  104. phone: '',
  105. pay_type: 0,
  106. btn_type: 1,
  107. ifPay: true,
  108. order_id: 0,
  109. enter_type: 0,
  110. payState: true,
  111. pay_order_id: 0
  112. }
  113. },
  114. onLoad(e) {
  115. this.goods_id = e.goods_id;
  116. this.btn_type = e.btn_type;
  117. this.order_id = e.order_id;
  118. this.enter_type = e.enter_type;
  119. if(this.goods_id) {
  120. this.getGoodsData(this.pay_type);
  121. }
  122. if(this.order_id && this.enter_type == 1) {
  123. console.log('con列表执行')
  124. this.payOnce()
  125. }
  126. },
  127. onShow(e) {
  128. let that = this
  129. uni.$on('payState',(data) => {
  130. that.payState = data.msg;
  131. that.pay_order_id = data.payorder_id;
  132. console.log('传来的订单id',that.pay_order_id)
  133. if(that.payState == true) {
  134. that.$url('/pages/payState/paystate?ifSuccess=1&order_id='+that.pay_order_id,{type: 'redirect'})
  135. }else {
  136. that.$url('/pages/payState/paystate?ifSuccess=2&order_id='+that.pay_order_id,{type: 'redirect'})
  137. }
  138. })
  139. },
  140. methods: {
  141. payStatus(type) {
  142. if(type == this.pay_type) {
  143. this.pay_type = type;
  144. return
  145. }else {
  146. this.pay_type = type;
  147. this.getGoodsData(type);
  148. }
  149. },
  150. getGoodsData(type){
  151. this.$http(this.API.API_CONFIRMDETAILS,{id: this.goods_id,num: 1,pay_type: type}).then(res => {
  152. this.goods_details = res.data;
  153. console.log('数据',res)
  154. })
  155. },
  156. submit() {
  157. if(this.order_id && this.enter_type == 1) {
  158. this.payOnce()
  159. return
  160. }
  161. if(!this.contact) {
  162. this.$msg('请输入联系人!');
  163. return;
  164. }
  165. if(!this.phone) {
  166. this.$msg('请输入联系电话!');
  167. return;
  168. }
  169. if(!this.ifPay) return;
  170. this.ifPay = false;
  171. 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 => {
  172. this.pay_order_id = res.data.id
  173. if(this.pay_type == 1) {
  174. this.ifPay = true
  175. this.$url('/pages/payState/paystate?ifSuccess=1&order_id='+res.data.id,{type: 'redirect'})
  176. }else if(res.data.jump == true) {
  177. let that = this;
  178. wx.navigateToMiniProgram({
  179. appId: res.data.jump_appid,
  180. path: '/pages/order/confirm_atonce',
  181. envVersion: 'release',
  182. extraData: {
  183. order_id: res.data.id
  184. },
  185. success(res) {
  186. console.log('---res---');
  187. that.ifPay = true;
  188. console.log(res);
  189. },
  190. fail(err) {
  191. console.log('---err---');
  192. console.log(err);
  193. that.ifPay = true;
  194. }
  195. })
  196. }
  197. }).catch(err => {
  198. this.ifPay = true
  199. })
  200. },
  201. payOnce() {
  202. this.$http(this.API.API_ORDERPAY,{id: this.order_id}).then(res => {
  203. if(res.data.jump) {
  204. wx.navigateToMiniProgram({
  205. appId: res.data.jump_appid,
  206. path: '/pages/order/confirm_atonce',
  207. envVersion: 'release',
  208. extraData: {
  209. order_id: res.data.id
  210. },
  211. success(res) {
  212. console.log('---res---')
  213. console.log(res)
  214. },
  215. fail(err) {
  216. console.log('---err---')
  217. console.log(err)
  218. }
  219. })
  220. }
  221. }).catch(err => {})
  222. }
  223. }
  224. }
  225. </script>
  226. <style>
  227. .btn{
  228. margin: 0;
  229. padding: 0;
  230. width: 212rpx;
  231. height: 82rpx;
  232. background-color: #1998FE;
  233. color: #FFFFFF;
  234. line-height: 80rpx;
  235. font-size: 32rpx;
  236. border-radius: 41rpx;
  237. }
  238. .bref-box {
  239. text-overflow: -o-ellipsis-lastline;
  240. overflow: hidden;
  241. text-overflow: ellipsis;
  242. display: -webkit-box;
  243. -webkit-line-clamp: 2;
  244. -webkit-box-orient: vertical;
  245. }
  246. </style>