时空网前端
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.

236 lines
6.7 KiB

  1. <template>
  2. <view>
  3. <!-- 商品信息 -->
  4. <block v-if="isRight(orderDetails)">
  5. <view class="bg-white padding-tb-sm">
  6. <skeleton :loading="skeletonLoading" :row="2" :showAvatar="false" :showTitle="true">
  7. <view class="flex justify-between align-start padding-top-sm padding-lr">
  8. <image :src="orderDetails.goods.cover" mode="aspectFill" style="width: 240rpx; height: 240rpx;border-radius: 10rpx;"></image>
  9. <view class="flex-sub padding-left-sm">
  10. <view class="bref-box margin-top-xs lf-line-2 lf-font-32 lf-font-bold" style="height: 88rpx;line-height: 44rpx;color: #222;">
  11. {{orderDetails.goods.name}}
  12. </view>
  13. <view class="flex justify-between align-center text-center">
  14. <text class="block margin-top-sm text-gray lf-font-28" style="margin-top: 20rpx;line-height: 40rpx;">数量</text>
  15. <view class="flex align-center margin-top-sm">
  16. <text class="lf-iconfont lf-icon-jianhao lf-font-40" style="color: #999;"></text>
  17. <input type="number" v-model="num" :disabled="true" class="text-center margin-lr-sm radius text-black lf-font-32" style="width: 60rpx; height: 50rpx;background-color: #f1f1f1;color: #222;" />
  18. <text class="lf-iconfont lf-icon-jiahao lf-font-40" style="color: #999;"></text>
  19. </view>
  20. </view>
  21. <view class="flex justify-between margin-top-sm">
  22. <lf-price :price="orderDetails.goods.specs[0].selling_price" />
  23. <!-- <view class="text-red text-price lf-font-42 lf-font-bold" style="margin-top: 12rpx;">
  24. {{Number(orderDetails.goods.specs[0].selling_price || 0)}}
  25. </view> -->
  26. </view>
  27. </view>
  28. </view>
  29. </skeleton>
  30. </view>
  31. <self-line/>
  32. <skeleton :loading="skeletonLoading" :row="1" :showAvatar="false" :showTitle="true">
  33. <view class="bg-white">
  34. <view class="cu-bar padding-lr">
  35. <text class="text-gray lf-font-32">优惠</text>
  36. <text class="lf-font-32 text-black1">暂无优惠</text>
  37. </view>
  38. </view>
  39. </skeleton>
  40. <self-line/>
  41. <skeleton :loading="skeletonLoading" :row="13" :showAvatar="false" :showTitle="true">
  42. <view class="btn-bottom">
  43. <view class="padding-lr padding-tb-sm bg-white flex justify-between align-center shadow">
  44. <view class="flex align-center">
  45. <text class="lf-font-28 text-gray">应付款</text>
  46. <lf-price :price="total(num, orderDetails.goods.specs[0].selling_price)" />
  47. <!-- <view class="text-red text-price lf-font-42 lf-font-bold">
  48. {{ total(num, orderDetails.goods.specs[0].selling_price) }}
  49. </view> -->
  50. </view>
  51. <button class="cu-btn block bg-orange round shadow" @tap="submit">
  52. <text class="lf-font-32 text-white" v-if="type == 1">立即付款</text>
  53. <text class="lf-font-32 text-white" v-else>下单付款</text>
  54. </button>
  55. </view>
  56. </view>
  57. </skeleton>
  58. </block>
  59. </view>
  60. </template>
  61. <script>
  62. import bigc from '@/common/bigc.js';
  63. export default {
  64. data() {
  65. return {
  66. num: 1,
  67. skeletonLoading: true,
  68. checkbox: [{
  69. value: 'A',
  70. checked: true
  71. }],
  72. goods_id: 1,
  73. goods_specs_id: 1,
  74. orderDetails: {},
  75. ifchoose: true,
  76. ifCheck: true,
  77. type: 0,
  78. order_id: 0,
  79. ifDo: 1,
  80. ifPay: true
  81. }
  82. },
  83. computed: {
  84. total(){
  85. return function(num, price){
  86. let big_num = new bigc(Number(num));
  87. big_num = big_num.times(Number(price));
  88. return big_num.round(2, 0).toString();
  89. }
  90. },
  91. isRight(){
  92. return function(val){
  93. return this.$shared.isRight(val);
  94. }
  95. }
  96. },
  97. onLoad(e) {
  98. this.type = e.type;
  99. this.goods_id = e.goods_id;
  100. this.order_id = e.order_id;
  101. this.goods_specs_id = e.goods_specs_id
  102. this.num = e.order_number
  103. if(this.goods_id && this.goods_specs_id && this.order_id) {
  104. this.getConfirmOrder()
  105. this.submit()
  106. }
  107. },
  108. methods: {
  109. getConfirmOrder() {
  110. this.$http(this.API.API_COFIRMORDER_DETAILS, {goods_id: this.goods_id,goods_specs_id: this.goods_specs_id}).then(res => {
  111. this.orderDetails = res.data
  112. this.skeletonLoading = false
  113. })
  114. },
  115. reduce() {
  116. if (this.num === 1) return
  117. this.num--
  118. },
  119. add() {
  120. this.num++
  121. },
  122. CheckboxChange(e) {
  123. if(e.detail.value != '') {
  124. this.ifchoose = true
  125. }else {
  126. this.ifchoose = false
  127. }
  128. },
  129. // 点击复制
  130. copy(text) {
  131. uni.setClipboardData({
  132. data: text
  133. });
  134. },
  135. submit(){
  136. if(!this.ifPay) return;
  137. this.ifPay = false;
  138. if(this.type == 1){
  139. this.pay();
  140. return;
  141. }
  142. this.$http(this.API.API_PRPAID, {
  143. goods_id: this.goods_id,
  144. goods_specs_id: this.goods_specs_id,
  145. number: this.num,
  146. }).then(res => {
  147. this.order_id = res.data.order_id
  148. uni.requestPayment({
  149. orderInfo: res.data.order_num,
  150. timeStamp: res.data.timeStamp,
  151. nonceStr: res.data.nonceStr,
  152. package: res.data.package,
  153. signType: res.data.signType,
  154. paySign: res.data.paySign,
  155. success: (res) => {
  156. this.ifPay = true
  157. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  158. },
  159. fail: (err) => {
  160. this.ifPay = true
  161. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  162. },
  163. })
  164. }).catch(err => {
  165. this.ifPay = true
  166. if(err.code == 9997) {
  167. uni.showModal({
  168. title: '提示',
  169. content: '是否同意前往手机授权?',
  170. success: e => {
  171. if (!e.confirm) return;
  172. this.$routerGo('/pages/login/index?type=phone')
  173. }
  174. });
  175. }
  176. });
  177. },
  178. pay(){
  179. this.$http(this.API.API_PAYMENT_DIRECT, {order_id: this.order_id}).then(res => {
  180. this.order_id = res.data.order_id
  181. uni.requestPayment({
  182. orderInfo: res.data.order_num,
  183. timeStamp: res.data.timeStamp,
  184. nonceStr: res.data.nonceStr,
  185. package: res.data.package,
  186. signType: res.data.signType,
  187. paySign: res.data.paySign,
  188. success: (res) => {
  189. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  190. },
  191. fail: (err) => {
  192. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  193. },
  194. })
  195. }).catch(err => {
  196. setTimeout(() => {
  197. this.$toBack()
  198. },1000)
  199. });
  200. },
  201. //下拉刷新
  202. downCallback() {
  203. this.getConfirmOrder()
  204. },
  205. },
  206. onShow() {
  207. if(this.ifDo > 1) {
  208. this.getConfirmOrder()
  209. }
  210. this.ifDo++
  211. }
  212. }
  213. </script>
  214. <style lang="scss" scoped>
  215. .bref-box {
  216. text-overflow: -o-ellipsis-lastline;
  217. overflow: hidden;
  218. text-overflow: ellipsis;
  219. display: -webkit-box;
  220. -webkit-line-clamp: 2;
  221. -webkit-box-orient: vertical;
  222. }
  223. </style>