detail.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view>
  3. <swiper class="swiper">
  4. <swiper-item v-for="item in files" :key="item.attachmentid">
  5. <u--image :src="item.cover" :lazy-load="true" width="100vw" :height="tovw(377)"
  6. @click.stop="previewImg(item.url)">
  7. <template v-slot:loading>
  8. <u-loading-icon color="red" />
  9. </template>
  10. </u--image>
  11. </swiper-item>
  12. </swiper>
  13. <view class="head">
  14. <view class="name">{{ detail.name || '--' }}</view>
  15. <text class="model u-line-1" v-if="detail.model">型号:{{ detail.model }}</text>
  16. <text class="subtitle u-line-1" v-if="detail.subtitle">{{detail.subtitle}}</text>
  17. </view>
  18. <!-- <text class="descript">注:价格不能超过4000元/台</text> -->
  19. <view class="price-content">
  20. <view class="item-box">
  21. <text class="price-label">付款方式:</text>
  22. <u-radio-group v-model="detail.pricetype"
  23. @change="init()">
  24. <u-radio :customStyle="{marginRight:tovw(50)}" key="一口价" label="一口价" name="一口价" />
  25. <u-radio :customStyle="{}" key="阶梯价" label="阶梯价" name="阶梯价" />
  26. </u-radio-group>
  27. </view>
  28. <AForm ref="form" :form="form" @isUncomplete="isUncomplete"></AForm>
  29. </view>
  30. <view :style="{height: tovw(80)}" ></view>
  31. <view class="footer">
  32. <view class="add" :class="uncomplete ? 'forbidden' : ''" hover-class="navigator-hover"
  33. @click="uncomplete || loading ? '' : submit()">
  34. <u-loading-icon v-if="loading" />
  35. <block v-else>
  36. {{ '保存' }}
  37. </block>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import AForm from '../../components/my_form2.vue'
  44. import { viewImage, formattedFiles } from "../../utils/settleFiles"
  45. export default {
  46. components:{AForm},
  47. data () {
  48. return {
  49. files:[],
  50. detail: {
  51. sa_fadid:'',
  52. },
  53. form:[],
  54. uncomplete:false,
  55. loading:false,
  56. }
  57. },
  58. onLoad (options) {
  59. this.detail.sa_fadid = options.id
  60. this.getDetail()
  61. },
  62. methods: {
  63. isUncomplete(uncomplete,actions) {
  64. console.log(uncomplete,'验证');
  65. this.uncomplete = uncomplete;
  66. },
  67. submit() {
  68. this.loading = true;
  69. let that = this;
  70. // let is = this.$refs.form.list.some(v=> {
  71. // if (v.inputmode == 'digit' && v.value > 4000) {
  72. // uni.showToast({
  73. // title:'价格<=4000元'
  74. // })
  75. // return true
  76. // } else {
  77. // false
  78. // }
  79. // })
  80. // if (is) return this.loading = false
  81. this.$refs.form.submit().then(data => {
  82. let form = Object.assign({},that.detail,data)
  83. form.sys_enterpriseid = uni.getStorageSync('shop').sys_enterpriseid
  84. this.$Http.basic({
  85. "id": 20240428154102,
  86. "content": form
  87. }).then(async res => {
  88. console.log("修改信息", res)
  89. if (this.cutoff(res.msg)) return;
  90. that.getDetail()
  91. uni.showToast({
  92. title:'修改成功'
  93. })
  94. this.$Http.editProduct()
  95. setTimeout(() => {
  96. this.loading = false;
  97. uni.navigateBack()
  98. },400)
  99. })
  100. })
  101. },
  102. previewImg(url) {
  103. viewImage(url)
  104. },
  105. getDetail() {
  106. this.$Http.basic({
  107. "id": "20240428154202",
  108. "content": {
  109. "sa_fadid": this.detail.sa_fadid
  110. }
  111. }).then(res => {
  112. if (this.cutoff(res.msg)) return;
  113. this.files = formattedFiles(res.data.attinfos_pic.map(v => v.attinfos[0])).map((v, i) => {
  114. if (v.fileType == 'image') v.cover = this.getSpecifiedImage(v, 'compressed')
  115. if (i == 0) res.data.cover = v.cover;
  116. return v
  117. })
  118. this.detail = res.data;
  119. this.detail.isonsale = this.detail.isonsale+''
  120. this.init()
  121. console.log(this.files,this.detail,'数据');
  122. uni.setNavigationBarTitle({
  123. title: '编辑商品'
  124. });
  125. })
  126. },
  127. async init () {
  128. let form
  129. if (this.detail.pricetype == '一口价') {
  130. form = [{
  131. key: "price",
  132. type: "text",
  133. inputmode:'digit',
  134. label: "价格(元/",
  135. isMust: true,//是否必填
  136. value: "",
  137. descript:'官方指导价:',
  138. },{
  139. key: "tag",
  140. type: "text",
  141. inputmode:'text',
  142. label: "标签",
  143. isMust: false,//是否必填
  144. value: "",
  145. paddingBottom:15,
  146. borderRadius:true,
  147. descript:'官方建议:'
  148. },{
  149. key: "isonsale",
  150. type: "radio",
  151. options:[{label:'上架',name:'1',marginRight:50},{label:'下架',name:'0'}],
  152. label: "状态",
  153. isMust: true,//是否必填
  154. value: "",
  155. }]
  156. } else {
  157. form = [{
  158. key: "price_rebate",
  159. type: "text",
  160. inputmode:'digit',
  161. label: "总部返利价(元/",
  162. isMust: true,//是否必填
  163. value: "",
  164. descript:'官方指导价:',
  165. },{
  166. key: "price_original",
  167. type: "text",
  168. inputmode:'digit',
  169. label: "原价(元/",
  170. isMust: true,//是否必填
  171. value: "",
  172. paddingBottom:15,
  173. descript:'官方指导价:',
  174. },{
  175. key: "price_store",
  176. type: "text",
  177. inputmode:'digit',
  178. label: "店面最低价(元/",
  179. isMust: true,//是否必填
  180. value: "",
  181. paddingBottom:15,
  182. descript:'官方指导价:',
  183. },{
  184. key: "price_deposit",
  185. type: "text",
  186. inputmode:'digit',
  187. label: "定金(元/",
  188. isMust: true,//是否必填
  189. value: "",
  190. paddingBottom:15,
  191. descript:'官方指导价:',
  192. },{
  193. key: "tag",
  194. type: "text",
  195. inputmode:'text',
  196. label: "标签",
  197. isMust: false,//是否必填
  198. value: "",
  199. paddingBottom:15,
  200. borderRadius:true,
  201. descript:'官方建议:'
  202. },{
  203. key: "isonsale",
  204. type: "radio",
  205. options:[{label:'上架',name:'1',marginRight:50},{label:'下架',name:'0'}],
  206. label: "状态",
  207. isMust: true,//是否必填
  208. value: "",
  209. }]
  210. }
  211. form = form.map(v => {
  212. if (v.key == 'tag') v.descript = v.descript + this.detail.officialinfo[v.key]
  213. if (v.key != 'isonsale' && v.key != 'tag') {
  214. v.descript = v.descript + this.detail.officialinfo[v.key]
  215. v.label = v.label + this.detail.unitname + ')'
  216. }
  217. v.value = this.detail[v.key] || v.value
  218. return v
  219. })
  220. this.form = form
  221. console.log(this.form,'value');
  222. },
  223. },
  224. }
  225. </script>
  226. <style lang="scss">
  227. .swiper {
  228. width: 100vw;
  229. height: 377px;
  230. }
  231. .descript {
  232. font-weight: 400;
  233. font-size: 14px;
  234. color: #E3041F;
  235. padding-left: 10px;
  236. }
  237. .price-content {
  238. background: #ffffff;
  239. margin-top: 10px;
  240. .item-box {
  241. display: flex;
  242. align-content: center;
  243. align-items: center;
  244. padding: 15px 0 0 10px;
  245. .price-label {
  246. margin-right: 10px;
  247. color: #666666;
  248. }
  249. }
  250. }
  251. .head {
  252. position: relative;
  253. background: #fff;
  254. padding: 10px;
  255. box-sizing: border-box;
  256. margin-bottom: 10px;
  257. .name {
  258. width: 280px;
  259. height: 24px;
  260. line-height: 24px;
  261. font-family: Source Han Sans SC, Source Han Sans SC;
  262. font-weight: bold;
  263. font-size: 16px;
  264. color: #333333;
  265. margin-bottom: 10px;
  266. }
  267. text {
  268. font-weight: 400;
  269. font-size: 12px;
  270. color: #999999;
  271. }
  272. .model {
  273. margin-bottom: 5px;
  274. }
  275. }
  276. .footer {
  277. position: fixed;
  278. bottom: 0;
  279. width: 100vw;
  280. height: 65px;
  281. background: #FFFFFF;
  282. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  283. box-sizing: border-box;
  284. padding: 5px 10px;
  285. z-index: 5;
  286. display: flex;
  287. .add {
  288. display: flex;
  289. align-items: center;
  290. justify-content: center;
  291. width: 100%;
  292. height: 45px;
  293. background: #C30D23;
  294. border-radius: 5px;
  295. font-family: PingFang SC, PingFang SC;
  296. font-size: 14px;
  297. color: #FFFFFF;
  298. }
  299. .forbidden {
  300. opacity: .6;
  301. }
  302. }
  303. </style>