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

304 lines
8.9 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
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 lf-font-32 lf-line-2 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 @blur="changeNum(num)" 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[choose_tag].selling_price" />
  23. <!-- <view class="text-red text-price lf-font-42 lf-font-bold" style="margin-top: 12rpx;">
  24. {{Number(orderDetails.goods.specs[choose_tag].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)" class="text-orange">{{orderDetails.agreement.title}}</text>在小程序下单购买即表示您已默认同意<text class="text-orange" @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[choose_tag].selling_price)" />
  57. <!-- <view class="text-red text-price lf-font-42 lf-font-bold">
  58. {{ total(num, orderDetails.goods.specs[choose_tag].selling_price) }}
  59. </view> -->
  60. </view>
  61. <button class="btn" @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. limit: 1,
  92. pt: 1,
  93. share_id: 1,
  94. choose_tag: 0
  95. }
  96. },
  97. computed: {
  98. total(){
  99. return function(num, price){
  100. let new_num = Number(num);
  101. if(Object.is(new_num, NaN)){
  102. return 0;
  103. };
  104. let big_price = new bigc(Number(price));
  105. big_price = big_price.times(new_num);
  106. return big_price.round(2, 0).toString();
  107. }
  108. },
  109. isRight(){
  110. return function(val){
  111. return this.$shared.isRight(val);
  112. }
  113. }
  114. },
  115. onLoad(e) {
  116. this.type = e.type;
  117. this.goods_id = e.goods_id;
  118. this.pt = e.pt || 1;
  119. this.order_id = e.order_id;
  120. this.goods_specs_id = e.goods_specs_id
  121. this.share_id = e.share_id
  122. this.choose_tag = e.choose_tag
  123. console.log('xuanze',this.choose_tag)
  124. if(this.goods_id && this.goods_specs_id) {
  125. this.getConfirmOrder()
  126. }
  127. },
  128. methods: {
  129. changeNum(num) {
  130. if(num > this.limit) {
  131. if(this.limit == 0 || this.limit == '') {
  132. this.num = num
  133. }else {
  134. this.$msg('该商品限购'+this.limit+'件')
  135. this.num = this.limit
  136. return
  137. }
  138. }else if(num < 1) {
  139. this.num = 1
  140. }
  141. },
  142. getConfirmOrder() {
  143. this.$http(this.API.API_COFIRMORDER_DETAILS, {goods_id: this.goods_id,goods_specs_id: this.goods_specs_id}).then(res => {
  144. this.orderDetails = res.data
  145. this.limit = res.data.goods.specs[this.choose_tag].limit
  146. // this.limit = 10
  147. this.skeletonLoading = false
  148. })
  149. },
  150. reduce() {
  151. if (this.num === 1 || this.num === 0) return
  152. this.num--
  153. },
  154. add() {
  155. if(this.num < this.limit) {
  156. this.num++
  157. }else if(this.limit == 0 || this.limit == ''){
  158. this.num++
  159. }else {
  160. this.$msg('该商品限购'+this.limit+'件')
  161. this.num = this.limit
  162. return
  163. }
  164. },
  165. CheckboxChange(e) {
  166. if(e.detail.value != '') {
  167. this.ifchoose = true
  168. }else {
  169. this.ifchoose = false
  170. }
  171. },
  172. // 点击复制
  173. copy(text) {
  174. uni.setClipboardData({
  175. data: text
  176. });
  177. },
  178. submit(){
  179. if(this.total(this.num,this.orderDetails.goods.specs[this.choose_tag].selling_price) == 0) {
  180. this.num = 1
  181. return this.$msg('商品数量格式不对!');
  182. }
  183. if(this.ifchoose == true) {
  184. if(!this.ifPay) return;
  185. this.ifPay = false;
  186. if(this.type == 1){
  187. this.pay();
  188. return;
  189. }
  190. this.$http(this.API.API_PRPAID, {
  191. goods_id: this.goods_id,
  192. goods_specs_id: this.goods_specs_id,
  193. number: this.num,
  194. payment_desc: this.pt,
  195. share_one: this.share_id || 0
  196. }).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.ifPay = true
  207. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  208. },
  209. fail: (err) => {
  210. this.ifPay = true
  211. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  212. },
  213. })
  214. }).catch(err => {
  215. this.ifPay = true
  216. if(err.code == 9997) {
  217. uni.showModal({
  218. title: '提示',
  219. content: '是否同意前往手机授权?',
  220. success: e => {
  221. if (!e.confirm) return;
  222. this.$routerGo('/pages/login/index?type=phone')
  223. }
  224. });
  225. }
  226. });
  227. }else {
  228. this.$msg('请认真阅读并同意协议!')
  229. return
  230. }
  231. },
  232. pay(){
  233. this.$http(this.API.API_PAYMENT_DIRECT, {order_id: this.order_id}).then(res => {
  234. this.order_id = res.data.order_id
  235. uni.requestPayment({
  236. orderInfo: res.data.order_num,
  237. timeStamp: res.data.timeStamp,
  238. nonceStr: res.data.nonceStr,
  239. package: res.data.package,
  240. signType: res.data.signType,
  241. paySign: res.data.paySign,
  242. success: (res) => {
  243. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  244. },
  245. fail: (err) => {
  246. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  247. },
  248. })
  249. }).catch(err => {
  250. setTimeout(() => {
  251. this.$toBack()
  252. },1000)
  253. });
  254. },
  255. //下拉刷新
  256. downCallback() {
  257. this.getConfirmOrder()
  258. },
  259. },
  260. onShow() {
  261. if(this.ifDo > 1) {
  262. this.getConfirmOrder()
  263. }
  264. this.ifDo++
  265. }
  266. }
  267. </script>
  268. <style lang="scss" scoped>
  269. .btn{
  270. margin: 0;
  271. padding: 0;
  272. width: 208rpx;
  273. height: 80rpx;
  274. background-color: #FE9903;
  275. color: #FFFFFF;
  276. line-height: 80rpx;
  277. font-size: 32rpx;
  278. border-radius: 42rpx;
  279. }
  280. .bref-box {
  281. text-overflow: -o-ellipsis-lastline;
  282. overflow: hidden;
  283. text-overflow: ellipsis;
  284. display: -webkit-box;
  285. -webkit-line-clamp: 2;
  286. -webkit-box-orient: vertical;
  287. }
  288. </style>