commodityDetails.vue 13 KB

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