detail.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view>
  3. <swiper class="screen-swiper square-dot" :indicator-dots="true" :circular="true" :autoplay="true" interval="5000"
  4. duration="500">
  5. <swiper-item v-for="(item,index) in goods.picall" :key="index">
  6. <image :src="item" mode="aspectFill"></image>
  7. </swiper-item>
  8. </swiper>
  9. <view class="echo-article-title bg-white">
  10. <text class="text-xl">{{goods.title}}</text>
  11. </view>
  12. <view class="echo-article-meta bg-white">
  13. <text>{{goods.summary}}</text>
  14. </view>
  15. <view class="echo-article-meta bg-white">
  16. <text class="text-xl text-red">{{goods.integral}}积分 + ¥{{goods.paymoney}}</text>
  17. </view>
  18. <view class="echo-article-meta bg-white">
  19. <view class="echo-article-meta-left">
  20. <text>库存: {{goods.stock}}件</text>
  21. </view>
  22. <view class="echo-article-meta-right">
  23. <text>已兑出:{{goods.sales}}件</text>
  24. </view>
  25. </view>
  26. <view class="bg-white padding-top-xs padding-bottom-sm margin-bottom"></view>
  27. <view class="cu-bar bg-white solids-bottom">
  28. <view class="action">
  29. <text class="cuIcon-titles text-blue"></text> 商品详情
  30. </view>
  31. </view>
  32. <view class="echo-article-details bg-white">
  33. <u-parse :content="goods.details" noData="详情内容..." @navigate="navigate"></u-parse>
  34. </view>
  35. <view class="padding-xl"></view>
  36. <view class="cu-bar bg-white tabbar border shop foot">
  37. <view class="bg-white submit">
  38. <view class="btn-group text-xxl flex justify-around">
  39. <view class="cuIcon-move" @tap="setNumber(-1)"></view>
  40. <view>{{buynumber}}</view>
  41. <view class="cuIcon-add" @tap="setNumber(1)"></view>
  42. </view>
  43. </view>
  44. <view class="bg-orange submit flex-wrap">
  45. <view style="width: 100%;">{{integral}} 积分</view>
  46. <view style="width: 100%;">¥{{paymoney}}</view>
  47. </view>
  48. <view class="bg-red submit" @tap="setOrder">立即订购</view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import uParse from '@/components/gaoyia-parse/parse.vue';
  54. var _this;
  55. export default {
  56. components: {
  57. uParse
  58. },
  59. data() {
  60. return {
  61. goods: {},
  62. isRotate: false,
  63. buynumber: 1,
  64. integral: 0,
  65. paymoney: 0.00
  66. }
  67. },
  68. onLoad: function(option) {
  69. _this = this;
  70. var goodsid = option.goodsid || 0;
  71. _this.$req.ajax({
  72. path: "mall/getgoods",
  73. data: {
  74. goodsid: goodsid
  75. }
  76. }).then((data) => {
  77. _this.goods = data.goods;
  78. _this.setNumber(0);
  79. }).catch((err) => {
  80. uni.showModal({
  81. title: '信息提示',
  82. content: err,
  83. showCancel: false
  84. });
  85. });
  86. },
  87. onShareAppMessage: function(res) {
  88. return {
  89. title: _this.goods.title,
  90. path: "/pages/mall/detail?goodsid=" + _this.goods.id
  91. }
  92. },
  93. methods: {
  94. setOrder: function() {
  95. if(_this.isRotate){
  96. return false;
  97. }
  98. _this.isRotate = true;
  99. var userinfo = uni.getStorageSync('userinfo') || false;
  100. if (userinfo == false) {
  101. uni.showModal({
  102. title: '信息提示',
  103. content: "你还未登录账号。",
  104. showCancel: false,
  105. success: function(res) {
  106. if (res.confirm) {
  107. uni.navigateTo({
  108. url: '/pages/login/login'
  109. });
  110. _this.isRotate = false;
  111. }
  112. }
  113. });
  114. return false;
  115. }
  116. var msg = "提交该订单将会扣除" + _this.integral + "积分";
  117. if (_this.paymoney != 0.00) {
  118. msg += ",并需要支付¥" + _this.paymoney + "元";
  119. }
  120. msg += "。确认要提交订单吗?";
  121. uni.showModal({
  122. title: '信息提示',
  123. content: msg,
  124. success: function(res) {
  125. if (res.confirm) {
  126. _this.$req.ajax({
  127. path: "mall/setorder",
  128. data: {
  129. goodsid: _this.goods.id,
  130. userid: userinfo.id,
  131. buynumber: _this.buynumber
  132. }
  133. }).then((data) => {
  134. uni.navigateTo({
  135. url: '/pages/mall/order?orderid=' + data.orderid
  136. });
  137. _this.isRotate = false;
  138. }).catch((err) => {
  139. uni.showModal({
  140. title: '信息提示',
  141. content: err,
  142. showCancel: false
  143. });
  144. });
  145. } else if (res.cancel) {
  146. _this.isRotate = false;
  147. }
  148. }
  149. });
  150. },
  151. setNumber: function(val) {
  152. var newbuynumber = parseInt(_this.buynumber) + val;
  153. newbuynumber = Math.max(1, newbuynumber);
  154. newbuynumber = Math.min(newbuynumber, parseInt(_this.goods.stock));
  155. _this.integral = (newbuynumber * _this.goods.integral);
  156. _this.paymoney = (newbuynumber * _this.goods.paymoney).toFixed(2);
  157. _this.buynumber = newbuynumber;
  158. },
  159. navigate: function(href, e) {
  160. // #ifdef H5
  161. location.href = href;
  162. // #endif
  163. // #ifndef H5
  164. uni.navigateTo({
  165. url: '/pages/tool/webview?pagesrc=' + encodeURIComponent(href)
  166. });
  167. // #endif
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss">
  173. .screen-swiper {
  174. height: 750rpx;
  175. }
  176. </style>