commodityDetails.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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;margin-left: 8rpx;">{{checkStatus == '通过'?Number(form.mallPrice) || 0:'***'}}<text style="font-size: 24rpx;margin-bottom: 8rpx;margin-left: 4rpx;">积分</text></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;margin-left: 8rpx;">{{checkStatus == '通过'?form.mallPrice || 0:'***'}}<text style="font-size: 24rpx;margin-bottom: 8rpx;margin-left: 4rpx;">积分</text></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>商品描述:{{form.detailsText?form.detailsText:'-'}}</text>
  150. </template>
  151. </u-cell>
  152. </u-cell-group>
  153. <view style="margin: 0 auto;" @click="arrow = !arrow">
  154. <u-icon name="arrow-up" labelPos="top" size="28" v-if="arrow"></u-icon>
  155. <u-icon name="arrow-down" labelPos="top" size="28" v-else></u-icon>
  156. </view>
  157. </view>
  158. <u-divider text="商品详情"></u-divider>
  159. <view style="width: 100%;margin-bottom: 100rpx;">
  160. <view v-html="form.detailsText"></view>
  161. </view>
  162. <view
  163. style="width: 100%;position: fixed;bottom: 0;background-color: #fff;border-top: 1rpx solid #ccc;padding-bottom: env(safe-area-inset-bottom);">
  164. <view style="width: 100%;display: flex;font-size: 24rpx;">
  165. <view @click="shoppingCart"
  166. style="width: 50%;display: grid;justify-items: center;padding: 10rpx 0;border-right: 1rpx solid #ccc;">
  167. <u-icon name="shopping-cart"></u-icon>
  168. <view>购物车</view>
  169. </view>
  170. <view @click="placeAnOrder" v-if="form.inventory > 0"
  171. style="width: 50%;background-color: #fd4b09;display: grid;justify-items: center;">
  172. <u-icon name="checkmark" color="#fff"></u-icon>
  173. <view style="color: #fff;">加入购物车</view>
  174. </view>
  175. <view @click="soldOut" v-else
  176. style="width: 50%;background-color: #969696;display: grid;justify-items: center;">
  177. <u-icon name="close" color="#fff"></u-icon>
  178. <view style="color: #fff;">已售罄</view>
  179. </view>
  180. </view>
  181. </view>
  182. <u-picker :show="showWarehouse" :columns="columns" :keyName="keyName" @confirm="confirmWarehouse"
  183. @cancel="showWarehouse = false"></u-picker>
  184. <!-- 提取去登录 -->
  185. <u-modal :show="adminShow" :showCancelButton="true" content='当前还未登录请先登录!!' @confirm="adminConfirm"
  186. @cancel="adminShow = false"></u-modal>
  187. </view>
  188. </template>
  189. <script>
  190. import {
  191. appDetail,
  192. addToCart,
  193. appModifyPrice,
  194. stockDescList,
  195. stockDescListV1
  196. } from '@/api/tabBar/home.js'
  197. export default {
  198. data() {
  199. return {
  200. checkboxValue: [],
  201. form: {
  202. shareList: []
  203. },
  204. arrow: true,
  205. dataList: [],
  206. screen: {},
  207. columns: [],
  208. keyName: '',
  209. showWarehouse: false,
  210. dataForm: {
  211. thisLocality: {},
  212. offsite: {}
  213. },
  214. inventoryFalse: true,
  215. inventoryData: [],
  216. // 审核状态
  217. checkStatus: '',
  218. adminShow: false,
  219. }
  220. },
  221. onLoad(onLoad) {
  222. this.checkStatus = uni.getStorageSync('checkStatus');
  223. appDetail(onLoad).then(res => {
  224. this.dataForm = res.data
  225. if (res.data.type == 0) {
  226. this.form = res.data.thisLocality
  227. } else {
  228. this.form = res.data.offsite
  229. }
  230. this.form.goodsNum = Number(this.form.goodsNum)
  231. this.stockDescListfun()
  232. })
  233. },
  234. methods: {
  235. // admin确认
  236. adminConfirm() {
  237. uni.clearStorageSync();
  238. uni.redirectTo({
  239. url: '/pages/login/login'
  240. })
  241. },
  242. // 轮播图点击预览
  243. swiperclick(e) {
  244. let arr = this.form.filesList.map(item => {
  245. return item.url
  246. })
  247. uni.previewImage({
  248. count: arr[e],
  249. current: e,
  250. urls: arr
  251. })
  252. },
  253. inventoryFalsefun() {
  254. this.inventoryFalse = !this.inventoryFalse
  255. this.stockDescListfun()
  256. },
  257. // 库存查询
  258. stockDescListfun() {
  259. stockDescListV1({
  260. cname: this.form.cname,
  261. whether: 0
  262. }).then(res => {
  263. this.inventoryData = res.data.records
  264. })
  265. },
  266. soldOut() {
  267. uni.showToast({
  268. icon: "none",
  269. title: '商品已售罄',
  270. mask: true
  271. });
  272. },
  273. backToHome() {
  274. uni.$u.route({
  275. url: 'pages/tabBar/home',
  276. type: "switchTab"
  277. })
  278. },
  279. // 加入购物车
  280. placeAnOrder() {
  281. if (uni.getStorageSync('userInfo').tenant_id == '000000') {
  282. this.adminShow = true
  283. return
  284. }
  285. uni.showLoading({
  286. title: '加载中',
  287. mask: true
  288. });
  289. addToCart({
  290. ...this.form,
  291. whetherIntegral: '1',
  292. detailsText: ''
  293. }).then(res => {
  294. uni.hideLoading();
  295. uni.showToast({
  296. title: "加入购物车成功",
  297. icon: "none",
  298. });
  299. }).catch(err => {
  300. uni.hideLoading();
  301. })
  302. },
  303. filterAll(screen) {
  304. this.screen = screen
  305. switch (screen[1]) {
  306. case "salesCompanyId":
  307. this.columns = [this.form.shareList]
  308. this.keyName = screen[1]
  309. this.showWarehouse = true
  310. break
  311. }
  312. },
  313. confirmWarehouse(e) {
  314. appModifyPrice({
  315. id: e.value[0].id
  316. }).then(res => {
  317. this.form.salesCompanyName = e.value[0].salesCompanyName
  318. this.form.salesCompanyId = e.value[0].salesCompanyId
  319. this.form.mallPrice = res.data.mallPrice
  320. this.form.inventory = res.data.inventory
  321. this.showWarehouse = false
  322. })
  323. },
  324. groupChange(val) {
  325. console.log(val)
  326. if (val == 0) {
  327. this.form = this.dataForm.thisLocality
  328. } else {
  329. this.form = this.dataForm.offsite
  330. }
  331. },
  332. shoppingCart() {
  333. uni.setStorageSync('tabKey', 2)
  334. uni.$u.route({url:'pages/integralMall/index'})
  335. }
  336. }
  337. }
  338. </script>
  339. <style scoped>
  340. /* page {
  341. background-color: #f2f2f2 !important;
  342. } */
  343. .head {
  344. width: calc(96% - 40rpx);
  345. margin: 0 auto;
  346. background-color: #FFFFFF;
  347. margin-top: 20rpx;
  348. border-radius: 20rpx;
  349. padding: 10rpx 20rpx 10rpx 20rpx;
  350. }
  351. .contentBox {
  352. width: 96%;
  353. margin: 20rpx auto;
  354. background-color: #FFFFFF;
  355. border-radius: 20rpx;
  356. /* box-shadow: 0 5rpx 14rpx 0 rgba(101, 176, 249, 0.42); */
  357. padding-top: 15rpx;
  358. padding-bottom: 10rpx;
  359. }
  360. .textBox {
  361. padding: 0 15px;
  362. display: flex;
  363. justify-content: space-between;
  364. font-size: 24rpx;
  365. margin-bottom: 10rpx;
  366. align-items: flex-end;
  367. }
  368. </style>