commodityDetails.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view style="padding-top: 0.01rpx;">
  3. <view style="width: 100%;margin: 0 auto;height: 800rpx;">
  4. <!-- <image v-for="(ite,ind) in form.filesList" :key="ind" v-if="ite.version === '0'" :src="ite.url" style="width: 100%;height: 100%;border-radius: 20rpx;"></image> -->
  5. <u-swiper :list="form.filesList" indicator indicatorMode="dot"
  6. :autoplay="false" height="800rpx" @click="swiperclick"></u-swiper>
  7. </view>
  8. <view class="contentBox">
  9. <view style="display: flex;align-items: center;">
  10. <view>
  11. <text style="font-size: 58rpx;color: red;margin-right: 20rpx;">¥{{checkStatus == '通过'?form.mallPrice || 0:'***'}}</text>
  12. <!-- <text style="font-size: 48rpx;text-decoration:line-through;">¥{{form.standardPrice}}</text> -->
  13. </view>
  14. <view style="display: flex;">
  15. <view v-if="form.billType == 0"
  16. style="font-size: 16rpx;background-color: #FD4B09;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  17. 今日达</view>
  18. <view v-else
  19. style="font-size: 16rpx;background-color: #5ac725;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  20. 次日达</view>
  21. </view>
  22. </view>
  23. <view>
  24. <text>{{form.cname}}</text>
  25. </view>
  26. </view>
  27. <view class="head">
  28. <u-cell-group title-bg-color="rgb(243, 244, 246)" :border="false">
  29. <u-cell :isLink="false" :border="false" center>
  30. <template slot="title">
  31. <u-radio-group
  32. v-model="dataForm.type"
  33. placement="row"
  34. @change="groupChange">
  35. <u-radio activeColor="#FD4B09" v-if="dataForm.thisLocality"
  36. :label="`今日达(库存:${~~(dataForm.thisLocality.inventory) > 10?'充足':~~(dataForm.thisLocality.inventory)})`" :name="0"></u-radio>
  37. <u-radio activeColor="#FD4B09" v-if="dataForm.offsite"
  38. :label="`次日达(库存:${~~(dataForm.offsite.inventory) > 10?'充足':~~(dataForm.offsite.inventory)})`" :name="1"></u-radio>
  39. </u-radio-group>
  40. </template>
  41. <template slot="value">
  42. <view>
  43. <u-icon :name="inventoryFalse?'arrow-up':'arrow-down'" @click="inventoryFalsefun()"></u-icon>
  44. </view>
  45. </template>
  46. </u-cell>
  47. </u-cell-group>
  48. <u-cell-group title-bg-color="rgb(243, 244, 246)" :border="false" v-if="inventoryFalse">
  49. <u-cell v-for="(item,index) in inventoryData" :key="index"
  50. :title="item.storageName" :value="Number(item.storeInventory) > 10?'充足':Number(item.storeInventory)"></u-cell>
  51. </u-cell-group>
  52. <u-cell-group title-bg-color="rgb(243, 244, 246)" :border="false">
  53. <!-- <u-cell title="所属公司:" :isLink="true" :border="false" center
  54. @click="filterAll(['salesCompanyName','salesCompanyId'])">
  55. <template slot="value">
  56. <text>{{form.salesCompanyName}}</text>
  57. </template>
  58. </u-cell> -->
  59. <u-cell :isLink="false" :border="false" center>
  60. <template slot="title">
  61. <!-- 一种利用符号进行的类型转换,转换成数字类型 -->
  62. <text>库存:{{form.inventory?~~(form.inventory) > 10?'充足':~~(form.inventory):''}}</text>
  63. </template>
  64. <template slot="value">
  65. <u-number-box v-model="form.goodsNum" :min="1" :max="form.inventory"></u-number-box>
  66. </template>
  67. </u-cell>
  68. </u-cell-group>
  69. </view>
  70. <view class="head">
  71. <u-cell-group title-bg-color="rgb(243, 244, 246)" :border="false" v-if="arrow">
  72. <u-cell :isLink="false" :border="false" center>
  73. <template slot="title">
  74. <text>规格型号:</text>
  75. </template>
  76. <template slot="value">
  77. <text>{{form.specificationAndModel||''}}</text>
  78. </template>
  79. </u-cell>
  80. <u-cell :isLink="false" :border="false" center>
  81. <template slot="title">
  82. <text>花纹:</text>
  83. </template>
  84. <template slot="value">
  85. <text>{{form.brandItem||''}}</text>
  86. </template>
  87. </u-cell>
  88. <u-cell :isLink="false" :border="false" center>
  89. <template slot="title">
  90. <text>产地:{{form.placeProduction||''}}</text>
  91. </template>
  92. <template slot="value">
  93. <text>防爆:{{form.explosionProof==1?"是":"否"}}</text>
  94. </template>
  95. </u-cell>
  96. <u-cell :isLink="false" :border="false" center>
  97. <template slot="title">
  98. <text>原厂:{{form.originalFactory==1?'是':'否'}}</text>
  99. </template>
  100. <template slot="value">
  101. <text>自修补:{{form.selfRecovery==1?'是':'否'}}</text>
  102. </template>
  103. </u-cell>
  104. </u-cell-group>
  105. <view style="margin: 0 auto;" @click="arrow = !arrow">
  106. <u-icon name="arrow-up" labelPos="top" size="28" v-if="arrow"></u-icon>
  107. <u-icon name="arrow-down" labelPos="top" size="28" v-else></u-icon>
  108. </view>
  109. </view>
  110. <u-divider text="商品详情"></u-divider>
  111. <view style="width: 100%;margin-bottom: 100rpx;">
  112. <view v-html="form.detailsText"></view>
  113. </view>
  114. <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;border-top: 1rpx solid #ccc;padding-bottom: env(safe-area-inset-bottom);">
  115. <view style="width: 100%;display: flex;font-size: 24rpx;">
  116. <view @click="shoppingCart"
  117. style="width: 25%;display: grid;justify-items: center;padding: 10rpx 0;border-right: 1rpx solid #ccc;">
  118. <u-icon name="shopping-cart"></u-icon>
  119. <view>购物车</view>
  120. </view>
  121. <view @click="placeAnOrder" v-if="form.inventory > 0"
  122. style="width: 75%;background-color: #fd4b09;display: grid;justify-items: center;">
  123. <u-icon name="checkmark" color="#fff"></u-icon>
  124. <view style="color: #fff;">加入购物车</view>
  125. </view>
  126. <view @click="soldOut" v-else
  127. style="width: 75%;background-color: #969696;display: grid;justify-items: center;">
  128. <u-icon name="close" color="#fff"></u-icon>
  129. <view style="color: #fff;">已售罄</view>
  130. </view>
  131. </view>
  132. </view>
  133. <u-picker :show="showWarehouse" :columns="columns" :keyName="keyName" @confirm="confirmWarehouse"
  134. @cancel="showWarehouse = false"></u-picker>
  135. </view>
  136. </template>
  137. <script>
  138. import {
  139. appDetail,
  140. addToCart,
  141. appModifyPrice,
  142. stockDescList
  143. } from '@/api/tabBar/home.js'
  144. export default {
  145. data() {
  146. return {
  147. checkboxValue:[],
  148. form: {
  149. shareList: []
  150. },
  151. arrow:false,
  152. dataList: [],
  153. screen: {},
  154. columns: [],
  155. keyName: '',
  156. showWarehouse: false,
  157. dataForm:{
  158. thisLocality:{},
  159. offsite:{}
  160. },
  161. inventoryFalse:false,
  162. inventoryData:[],
  163. // 审核状态
  164. checkStatus:'',
  165. }
  166. },
  167. onLoad(onLoad) {
  168. this.checkStatus = uni.getStorageSync('checkStatus');
  169. appDetail(onLoad).then(res => {
  170. this.dataForm = res.data
  171. if(res.data.type == 0){
  172. this.form = res.data.thisLocality
  173. }else{
  174. this.form = res.data.offsite
  175. }
  176. this.form.goodsNum = Number(this.form.goodsNum)
  177. })
  178. },
  179. methods: {
  180. // 轮播图点击预览
  181. swiperclick(e){
  182. let arr = this.form.filesList.map(item=>{
  183. return item.url
  184. })
  185. uni.previewImage({
  186. count:arr[e],
  187. current:e,
  188. urls:arr
  189. })
  190. },
  191. inventoryFalsefun(){
  192. this.inventoryFalse = !this.inventoryFalse
  193. this.stockDescListfun()
  194. },
  195. // 库存查询
  196. stockDescListfun(){
  197. stockDescList({
  198. cname:this.form.cname,
  199. whether:0
  200. }).then(res=>{
  201. this.inventoryData = res.data.records
  202. })
  203. },
  204. soldOut() {
  205. uni.showToast({
  206. icon: "none",
  207. title: '商品已售罄',
  208. mask: true
  209. });
  210. },
  211. backToHome() {
  212. uni.$u.route({
  213. url: 'pages/tabBar/home',
  214. type: "switchTab"
  215. })
  216. },
  217. placeAnOrder() {
  218. uni.showLoading({
  219. title: '加载中',
  220. mask: true
  221. });
  222. addToCart({
  223. ...this.form,
  224. detailsText: ''
  225. }).then(res => {
  226. uni.hideLoading();
  227. uni.showToast({
  228. title: "加入购物车成功",
  229. icon: "none",
  230. mask:true,
  231. duration:2500
  232. });
  233. }).catch(err => {
  234. uni.hideLoading();
  235. })
  236. },
  237. filterAll(screen) {
  238. this.screen = screen
  239. switch (screen[1]) {
  240. case "salesCompanyId":
  241. this.columns = [this.form.shareList]
  242. this.keyName = screen[1]
  243. this.showWarehouse = true
  244. break
  245. }
  246. },
  247. confirmWarehouse(e) {
  248. appModifyPrice({
  249. id: e.value[0].id
  250. }).then(res => {
  251. this.form.salesCompanyName = e.value[0].salesCompanyName
  252. this.form.salesCompanyId = e.value[0].salesCompanyId
  253. this.form.mallPrice = res.data.mallPrice
  254. this.form.inventory = res.data.inventory
  255. this.showWarehouse = false
  256. })
  257. },
  258. groupChange(val){
  259. console.log(val)
  260. if(val == 0){
  261. this.form = this.dataForm.thisLocality
  262. }else{
  263. this.form = this.dataForm.offsite
  264. }
  265. },
  266. shoppingCart() {
  267. uni.$u.route({
  268. url: 'pages/tabBar/shoppingCart',
  269. type: "switchTab"
  270. })
  271. }
  272. }
  273. }
  274. </script>
  275. <style scoped>
  276. /* page {
  277. background-color: #f2f2f2 !important;
  278. } */
  279. .head {
  280. width: calc(96% - 40rpx);
  281. margin: 0 auto;
  282. background-color: #FFFFFF;
  283. margin-top: 20rpx;
  284. border-radius: 20rpx;
  285. padding: 10rpx 20rpx 10rpx 20rpx;
  286. }
  287. .contentBox {
  288. width: 96%;
  289. margin: 20rpx auto;
  290. background-color: #FFFFFF;
  291. border-radius: 20rpx;
  292. /* box-shadow: 0 5rpx 14rpx 0 rgba(101, 176, 249, 0.42); */
  293. padding-top: 15rpx;
  294. padding-bottom: 10rpx;
  295. }
  296. .textBox {
  297. padding: 0 15px;
  298. display: flex;
  299. justify-content: space-between;
  300. font-size: 24rpx;
  301. margin-bottom: 10rpx;
  302. align-items: flex-end;
  303. }
  304. </style>