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

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