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

250 lines
7.7 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 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-jianshao lf-font-40" @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;" />
  18. <text class="lf-iconfont lf-icon-jia1 lf-font-40" @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="cuIcon-loading2 cuIconfont-spin margin-right-xs text-white" v-if="loading"></text>
  63. <text class="lf-font-32 text-white" v-if="type == 1">{{ loading ? '支付中...' : '立即付款' }}</text>
  64. <text class="lf-font-32 text-white" v-else>{{ loading ? '支付中...' : '下单付款' }}</text>
  65. </button>
  66. </view>
  67. </view>
  68. </skeleton>
  69. </block>
  70. </view>
  71. </template>
  72. <script>
  73. import bigc from '@/common/bigc.js';
  74. export default {
  75. data() {
  76. return {
  77. num: 1,
  78. base64Img: '', //
  79. skeletonLoading: true,
  80. loading: false,
  81. checkbox: [{
  82. value: 'A',
  83. checked: true
  84. }],
  85. goods_id: 1,
  86. goods_specs_id: 1,
  87. orderDetails: {},
  88. ifchoose: true,
  89. ifCheck: true,
  90. type: 0,
  91. order_id: 0,
  92. ifDo: 1,
  93. ifPay: true
  94. }
  95. },
  96. computed: {
  97. total(){
  98. return function(num, price){
  99. let big_num = new bigc(Number(num));
  100. big_num = big_num.times(Number(price));
  101. return big_num.round(2, 0).toString();
  102. }
  103. },
  104. isRight(){
  105. return function(val){
  106. return this.$shared.isRight(val);
  107. }
  108. }
  109. },
  110. onLoad(e) {
  111. this.type = e.type;
  112. this.goods_id = e.goods_id;
  113. this.order_id = e.order_id;
  114. this.goods_specs_id = e.goods_specs_id
  115. if(this.goods_id && this.goods_specs_id) {
  116. this.getConfirmOrder()
  117. }
  118. },
  119. methods: {
  120. getConfirmOrder() {
  121. this.$http(this.API.API_COFIRMORDER_DETAILS, {goods_id: this.goods_id,goods_specs_id: this.goods_specs_id}).then(res => {
  122. this.orderDetails = res.data
  123. this.skeletonLoading = false
  124. })
  125. },
  126. reduce() {
  127. if (this.num === 1) return
  128. this.num--
  129. },
  130. add() {
  131. this.num++
  132. },
  133. CheckboxChange(e) {
  134. if(e.detail.value != '') {
  135. this.ifchoose = true
  136. }else {
  137. this.ifchoose = false
  138. }
  139. },
  140. // 点击复制
  141. copy(text) {
  142. uni.setClipboardData({
  143. data: text
  144. });
  145. },
  146. submit(){
  147. if(this.ifchoose == true) {
  148. if(!this.ifPay) return;
  149. this.ifPay = false;
  150. if(this.type == 1){
  151. this.pay();
  152. return;
  153. }
  154. this.$http(this.API.API_PRPAID, {
  155. goods_id: this.goods_id,
  156. goods_specs_id: this.goods_specs_id,
  157. number: this.num,
  158. }).then(res => {
  159. this.order_id = res.data.order_id
  160. uni.requestPayment({
  161. orderInfo: res.data.order_num,
  162. timeStamp: res.data.timeStamp,
  163. nonceStr: res.data.nonceStr,
  164. package: res.data.package,
  165. signType: res.data.signType,
  166. paySign: res.data.paySign,
  167. success: (res) => {
  168. this.ifPay = true
  169. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  170. },
  171. fail: (err) => {
  172. this.ifPay = true
  173. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  174. },
  175. })
  176. }).catch(err => {
  177. this.ifPay = true
  178. if(err.code == 9997) {
  179. uni.showModal({
  180. title: '提示',
  181. content: '是否同意前往手机授权?',
  182. success: e => {
  183. if (!e.confirm) return;
  184. this.$routerGo('/pages/login/index?type=phone')
  185. }
  186. });
  187. }
  188. });
  189. }else {
  190. this.$msg('请认真阅读并同意协议!')
  191. return
  192. }
  193. },
  194. pay(){
  195. console.log("this.order_id", this.order_id)
  196. this.$http(this.API.API_PAYMENT_DIRECT, {order_id: this.order_id}).then(res => {
  197. this.order_id = res.data.order_id
  198. uni.requestPayment({
  199. orderInfo: res.data.order_num,
  200. timeStamp: res.data.timeStamp,
  201. nonceStr: res.data.nonceStr,
  202. package: res.data.package,
  203. signType: res.data.signType,
  204. paySign: res.data.paySign,
  205. success: (res) => {
  206. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  207. },
  208. fail: (err) => {
  209. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  210. },
  211. })
  212. })
  213. },
  214. //下拉刷新
  215. downCallback() {
  216. this.getConfirmOrder()
  217. },
  218. },
  219. onShow() {
  220. if(this.ifDo > 1) {
  221. this.getConfirmOrder()
  222. }
  223. this.ifDo++
  224. }
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. .bref-box {
  229. text-overflow: -o-ellipsis-lastline;
  230. overflow: hidden;
  231. text-overflow: ellipsis;
  232. display: -webkit-box;
  233. -webkit-line-clamp: 2;
  234. -webkit-box-orient: vertical;
  235. }
  236. </style>