commodityDetails.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. <!-- 提取去登录 -->
  136. <u-modal :show="adminShow" :showCancelButton="true" content='当前还未登录请先登录!!'
  137. @confirm="adminConfirm"
  138. @cancel="adminShow = false" ></u-modal>
  139. </view>
  140. </template>
  141. <script>
  142. import {
  143. appDetail,
  144. addToCart,
  145. appModifyPrice,
  146. stockDescList
  147. } from '@/api/tabBar/home.js'
  148. export default {
  149. data() {
  150. return {
  151. checkboxValue:[],
  152. form: {
  153. shareList: []
  154. },
  155. arrow:false,
  156. dataList: [],
  157. screen: {},
  158. columns: [],
  159. keyName: '',
  160. showWarehouse: false,
  161. dataForm:{
  162. thisLocality:{},
  163. offsite:{}
  164. },
  165. inventoryFalse:false,
  166. inventoryData:[],
  167. // 审核状态
  168. checkStatus:'',
  169. adminShow:false,
  170. }
  171. },
  172. onLoad(onLoad) {
  173. this.checkStatus = uni.getStorageSync('checkStatus');
  174. appDetail(onLoad).then(res => {
  175. this.dataForm = res.data
  176. if(res.data.type == 0){
  177. this.form = res.data.thisLocality
  178. }else{
  179. this.form = res.data.offsite
  180. }
  181. this.form.goodsNum = Number(this.form.goodsNum)
  182. })
  183. },
  184. methods: {
  185. // admin确认
  186. adminConfirm(){
  187. uni.clearStorageSync();
  188. uni.redirectTo({
  189. url: '/pages/login/login'
  190. })
  191. },
  192. // 轮播图点击预览
  193. swiperclick(e){
  194. let arr = this.form.filesList.map(item=>{
  195. return item.url
  196. })
  197. uni.previewImage({
  198. count:arr[e],
  199. current:e,
  200. urls:arr
  201. })
  202. },
  203. inventoryFalsefun(){
  204. this.inventoryFalse = !this.inventoryFalse
  205. this.stockDescListfun()
  206. },
  207. // 库存查询
  208. stockDescListfun(){
  209. stockDescList({
  210. cname:this.form.cname,
  211. whether:0
  212. }).then(res=>{
  213. this.inventoryData = res.data.records
  214. })
  215. },
  216. soldOut() {
  217. uni.showToast({
  218. icon: "none",
  219. title: '商品已售罄',
  220. mask: true
  221. });
  222. },
  223. backToHome() {
  224. uni.$u.route({
  225. url: 'pages/tabBar/home',
  226. type: "switchTab"
  227. })
  228. },
  229. // 加入购物车
  230. placeAnOrder() {
  231. if(uni.getStorageSync('userInfo').tenant_id == '000000') {
  232. this.adminShow = true
  233. return
  234. }
  235. uni.showLoading({
  236. title: '加载中',
  237. mask: true
  238. });
  239. addToCart({
  240. ...this.form,
  241. detailsText: ''
  242. }).then(res => {
  243. uni.hideLoading();
  244. uni.showToast({
  245. title: "加入购物车成功",
  246. icon: "none",
  247. mask:true,
  248. duration:2500
  249. });
  250. }).catch(err => {
  251. uni.hideLoading();
  252. })
  253. },
  254. filterAll(screen) {
  255. this.screen = screen
  256. switch (screen[1]) {
  257. case "salesCompanyId":
  258. this.columns = [this.form.shareList]
  259. this.keyName = screen[1]
  260. this.showWarehouse = true
  261. break
  262. }
  263. },
  264. confirmWarehouse(e) {
  265. appModifyPrice({
  266. id: e.value[0].id
  267. }).then(res => {
  268. this.form.salesCompanyName = e.value[0].salesCompanyName
  269. this.form.salesCompanyId = e.value[0].salesCompanyId
  270. this.form.mallPrice = res.data.mallPrice
  271. this.form.inventory = res.data.inventory
  272. this.showWarehouse = false
  273. })
  274. },
  275. groupChange(val){
  276. console.log(val)
  277. if(val == 0){
  278. this.form = this.dataForm.thisLocality
  279. }else{
  280. this.form = this.dataForm.offsite
  281. }
  282. },
  283. shoppingCart() {
  284. uni.$u.route({
  285. url: 'pages/tabBar/shoppingCart',
  286. type: "switchTab"
  287. })
  288. }
  289. }
  290. }
  291. </script>
  292. <style scoped>
  293. /* page {
  294. background-color: #f2f2f2 !important;
  295. } */
  296. .head {
  297. width: calc(96% - 40rpx);
  298. margin: 0 auto;
  299. background-color: #FFFFFF;
  300. margin-top: 20rpx;
  301. border-radius: 20rpx;
  302. padding: 10rpx 20rpx 10rpx 20rpx;
  303. }
  304. .contentBox {
  305. width: 96%;
  306. margin: 20rpx auto;
  307. background-color: #FFFFFF;
  308. border-radius: 20rpx;
  309. /* box-shadow: 0 5rpx 14rpx 0 rgba(101, 176, 249, 0.42); */
  310. padding-top: 15rpx;
  311. padding-bottom: 10rpx;
  312. }
  313. .textBox {
  314. padding: 0 15px;
  315. display: flex;
  316. justify-content: space-between;
  317. font-size: 24rpx;
  318. margin-bottom: 10rpx;
  319. align-items: flex-end;
  320. }
  321. </style>