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

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