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

249 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
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. <self-line/>
  6. <view class="bg-white padding-tb-sm">
  7. <skeleton :loading="skeletonLoading" :row="2" :showAvatar="false" :showTitle="true">
  8. <view class="flex justify-between align-start padding-top-sm padding-lr">
  9. <image :src="orderDetails.goods.cover" mode="aspectFill" style="width: 240rpx; height: 240rpx;border-radius: 10rpx;"></image>
  10. <view class="flex-sub padding-left-sm">
  11. <view class="bref-box margin-top-xs lf-font-32 lf-font-bold" style="height: 88rpx;line-height: 44rpx;color: #222;">
  12. {{orderDetails.goods.name}}
  13. </view>
  14. <view class="flex justify-between align-center text-center">
  15. <text class="block margin-top-sm text-gray lf-font-28" style="margin-top: 20rpx;line-height: 40rpx;">数量</text>
  16. <view class="flex align-center margin-top-sm">
  17. <text class="lf-iconfont lf-icon-jianshao" @tap="reduce"></text>
  18. <input type="number" v-model="num" class="text-center margin-lr-sm radius text-black lf-font-32" style="width: 60rpx; height: 50rpx;" />
  19. <text class="lf-iconfont lf-icon-jia1" @tap="add"></text>
  20. </view>
  21. </view>
  22. <view class="flex justify-between margin-top-sm">
  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. <button v-if="true" class="cu-btn line-orange round margin-left-sm text-sm">申请退款</button>
  28. <button v-else class="cu-btn line-gray bg-gray round margin-left-sm text-sm">退款中</button>
  29. </view> -->
  30. </view>
  31. </view>
  32. </view>
  33. </skeleton>
  34. </view>
  35. <self-line/>
  36. <skeleton :loading="skeletonLoading" :row="1" :showAvatar="false" :showTitle="true">
  37. <view class="bg-white">
  38. <view class="cu-bar padding-lr solid-bottom">
  39. <text class="text-gray lf-font-32">优惠</text>
  40. <text class="lf-font-32 text-black1">暂无优惠</text>
  41. </view>
  42. </view>
  43. </skeleton>
  44. <self-line/>
  45. <skeleton :loading="skeletonLoading" :row="13" :showAvatar="false" :showTitle="true">
  46. <view class="btn-bottom">
  47. <view class="padding flex justify-around align-center bg-gray1" v-if="orderDetails.agreement.title">
  48. <checkbox-group class="block" @change="CheckboxChange">
  49. <view class="margin-right">
  50. <checkbox @change="CheckboxChange" :class="checkbox[0].checked?'checked':''" :checked="checkbox[0].checked?true:false" value="A"></checkbox>
  51. </view>
  52. </checkbox-group>
  53. <view class="lf-font-24 text-gray">
  54. 请认真阅读并同意<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>的所有条款
  55. </view>
  56. </view>
  57. <view class="padding-lr padding-tb-sm bg-white flex justify-between align-center solid-top shadow">
  58. <view class="flex align-center">
  59. <text class="lf-font-28 text-gray">应付款</text>
  60. <view class="text-red text-price lf-font-42 lf-font-bold">
  61. {{Number(orderDetails.goods.specs[0].selling_price*num || 0)}}
  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. export default {
  76. data() {
  77. return {
  78. num: 1,
  79. base64Img: '', //
  80. skeletonLoading: true,
  81. loading: false,
  82. checkbox: [{
  83. value: 'A',
  84. checked: true
  85. }],
  86. goods_id: 1,
  87. goods_specs_id: 1,
  88. orderDetails: {},
  89. ifchoose: true,
  90. ifCheck: true,
  91. type: 0,
  92. order_id: 0,
  93. ifDo: 1
  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.type == 1){
  167. this.pay();
  168. return;
  169. }
  170. this.$http(this.API.API_PRPAID, {
  171. goods_id: this.goods_id,
  172. goods_specs_id: this.goods_specs_id,
  173. number: this.num,
  174. }).then(res => {
  175. this.order_id = res.data.order_id
  176. uni.requestPayment({
  177. orderInfo: res.data.order_num,
  178. timeStamp: res.data.timeStamp,
  179. nonceStr: res.data.nonceStr,
  180. package: res.data.package,
  181. signType: res.data.signType,
  182. paySign: res.data.paySign,
  183. success: (res) => {
  184. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  185. },
  186. fail: (err) => {
  187. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  188. },
  189. })
  190. })
  191. }
  192. }else {
  193. this.$msg('请认真阅读并同意协议!')
  194. return
  195. }
  196. },
  197. pay(){
  198. console.log("this.order_id", this.order_id)
  199. this.$http(this.API.API_PAYMENT_DIRECT, {order_id: this.order_id}).then(res => {
  200. this.order_id = res.data.order_id
  201. uni.requestPayment({
  202. orderInfo: res.data.order_num,
  203. timeStamp: res.data.timeStamp,
  204. nonceStr: res.data.nonceStr,
  205. package: res.data.package,
  206. signType: res.data.signType,
  207. paySign: res.data.paySign,
  208. success: (res) => {
  209. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  210. },
  211. fail: (err) => {
  212. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  213. },
  214. })
  215. })
  216. },
  217. //下拉刷新
  218. downCallback() {
  219. this.getConfirmOrder()
  220. },
  221. },
  222. onShow() {
  223. if(this.ifDo > 1) {
  224. this.getConfirmOrder()
  225. }
  226. this.ifDo++
  227. }
  228. }
  229. </script>
  230. <style lang="scss" scoped>
  231. .bref-box {
  232. text-overflow: -o-ellipsis-lastline;
  233. overflow: hidden;
  234. text-overflow: ellipsis;
  235. display: -webkit-box;
  236. -webkit-line-clamp: 2;
  237. -webkit-box-orient: vertical;
  238. }
  239. </style>