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

251 lines
7.6 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>
  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-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;" @tap="reduce"></text>
  17. <input type="number" v-model="num" 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;" @tap="add"></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 flex justify-around align-center bg-gray1" v-if="orderDetails.agreement.title">
  44. <checkbox-group class="block" @change="CheckboxChange">
  45. <view class="margin-right">
  46. <checkbox @change="CheckboxChange" :class="checkbox[0].checked?'checked':''" :checked="checkbox[0].checked?true:false" value="A"></checkbox>
  47. </view>
  48. </checkbox-group>
  49. <view class="lf-font-24 text-gray">
  50. 请认真阅读并同意<text @tap="$routerGo('/pages/agreement/agreement?id='+orderDetails.agreement.article_id)">{{orderDetails.agreement.title}}</text>在小程序下单购买即表示您已默认同意<text @tap="$routerGo('/pages/agreement/agreement?id='+orderDetails.agreement.article_id)">{{orderDetails.agreement.title}}</text>的所有条款
  51. </view>
  52. </view>
  53. <view class="padding-lr padding-tb-sm bg-white flex justify-between align-center shadow">
  54. <view class="flex align-center">
  55. <text class="lf-font-28 text-gray">应付款</text>
  56. <lf-price :price="total(num, orderDetails.goods.specs[0].selling_price)" />
  57. <!-- <view class="text-red text-price lf-font-42 lf-font-bold">
  58. {{ total(num, orderDetails.goods.specs[0].selling_price) }}
  59. </view> -->
  60. </view>
  61. <button class="cu-btn block bg-orange round shadow" @tap="submit">
  62. <text class="lf-font-32 text-white" v-if="type == 1">立即付款</text>
  63. <text class="lf-font-32 text-white" v-else>下单付款</text>
  64. </button>
  65. </view>
  66. </view>
  67. </skeleton>
  68. </block>
  69. </view>
  70. </template>
  71. <script>
  72. import bigc from '@/common/bigc.js';
  73. export default {
  74. data() {
  75. return {
  76. num: 1,
  77. skeletonLoading: true,
  78. checkbox: [{
  79. value: 'A',
  80. checked: true
  81. }],
  82. goods_id: 1,
  83. goods_specs_id: 1,
  84. orderDetails: {},
  85. ifchoose: true,
  86. ifCheck: true,
  87. type: 0,
  88. order_id: 0,
  89. ifDo: 1,
  90. ifPay: true
  91. }
  92. },
  93. computed: {
  94. total(){
  95. return function(num, price){
  96. let big_num = new bigc(Number(num));
  97. big_num = big_num.times(Number(price));
  98. return big_num.round(2, 0).toString();
  99. }
  100. },
  101. isRight(){
  102. return function(val){
  103. return this.$shared.isRight(val);
  104. }
  105. }
  106. },
  107. onLoad(e) {
  108. this.type = e.type;
  109. this.goods_id = e.goods_id;
  110. this.order_id = e.order_id;
  111. this.goods_specs_id = e.goods_specs_id
  112. if(this.goods_id && this.goods_specs_id) {
  113. this.getConfirmOrder()
  114. }
  115. },
  116. methods: {
  117. getConfirmOrder() {
  118. this.$http(this.API.API_COFIRMORDER_DETAILS, {goods_id: this.goods_id,goods_specs_id: this.goods_specs_id}).then(res => {
  119. this.orderDetails = res.data
  120. this.skeletonLoading = false
  121. })
  122. },
  123. reduce() {
  124. if (this.num === 1) return
  125. this.num--
  126. },
  127. add() {
  128. this.num++
  129. },
  130. CheckboxChange(e) {
  131. if(e.detail.value != '') {
  132. this.ifchoose = true
  133. }else {
  134. this.ifchoose = false
  135. }
  136. },
  137. // 点击复制
  138. copy(text) {
  139. uni.setClipboardData({
  140. data: text
  141. });
  142. },
  143. submit(){
  144. if(this.ifchoose == true) {
  145. if(!this.ifPay) return;
  146. this.ifPay = false;
  147. if(this.type == 1){
  148. this.pay();
  149. return;
  150. }
  151. this.$http(this.API.API_PRPAID, {
  152. goods_id: this.goods_id,
  153. goods_specs_id: this.goods_specs_id,
  154. number: this.num,
  155. }).then(res => {
  156. this.order_id = res.data.order_id
  157. uni.requestPayment({
  158. orderInfo: res.data.order_num,
  159. timeStamp: res.data.timeStamp,
  160. nonceStr: res.data.nonceStr,
  161. package: res.data.package,
  162. signType: res.data.signType,
  163. paySign: res.data.paySign,
  164. success: (res) => {
  165. this.ifPay = true
  166. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  167. },
  168. fail: (err) => {
  169. this.ifPay = true
  170. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  171. },
  172. })
  173. }).catch(err => {
  174. this.ifPay = true
  175. if(err.code == 9997) {
  176. uni.showModal({
  177. title: '提示',
  178. content: '是否同意前往手机授权?',
  179. success: e => {
  180. if (!e.confirm) return;
  181. this.$routerGo('/pages/login/index?type=phone')
  182. }
  183. });
  184. }
  185. });
  186. }else {
  187. this.$msg('请认真阅读并同意协议!')
  188. return
  189. }
  190. },
  191. pay(){
  192. console.log("this.order_id", this.order_id)
  193. this.$http(this.API.API_PAYMENT_DIRECT, {order_id: this.order_id}).then(res => {
  194. this.order_id = res.data.order_id
  195. uni.requestPayment({
  196. orderInfo: res.data.order_num,
  197. timeStamp: res.data.timeStamp,
  198. nonceStr: res.data.nonceStr,
  199. package: res.data.package,
  200. signType: res.data.signType,
  201. paySign: res.data.paySign,
  202. success: (res) => {
  203. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  204. },
  205. fail: (err) => {
  206. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  207. },
  208. })
  209. }).catch(err => {
  210. setTimeout(() => {
  211. this.$toBack()
  212. },1000)
  213. });
  214. },
  215. //下拉刷新
  216. downCallback() {
  217. this.getConfirmOrder()
  218. },
  219. },
  220. onShow() {
  221. if(this.ifDo > 1) {
  222. this.getConfirmOrder()
  223. }
  224. this.ifDo++
  225. }
  226. }
  227. </script>
  228. <style lang="scss" scoped>
  229. .bref-box {
  230. text-overflow: -o-ellipsis-lastline;
  231. overflow: hidden;
  232. text-overflow: ellipsis;
  233. display: -webkit-box;
  234. -webkit-line-clamp: 2;
  235. -webkit-box-orient: vertical;
  236. }
  237. </style>