detail.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. this.$Http.basic({
  84. "id": 20240428154102,
  85. "content": form
  86. }).then(async res => {
  87. this.loading = false;
  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. uni.navigateBack()
  97. },400)
  98. })
  99. })
  100. },
  101. previewImg(url) {
  102. viewImage(url)
  103. },
  104. getDetail() {
  105. this.$Http.basic({
  106. "id": "20240428154202",
  107. "content": {
  108. "sa_fadid": this.detail.sa_fadid
  109. }
  110. }).then(res => {
  111. if (this.cutoff(res.msg)) return;
  112. this.files = formattedFiles(res.data.attinfos_pic.map(v => v.attinfos[0])).map((v, i) => {
  113. if (v.fileType == 'image') v.cover = this.getSpecifiedImage(v, 'compressed')
  114. if (i == 0) res.data.cover = v.cover;
  115. return v
  116. })
  117. this.detail = res.data;
  118. this.detail.isonsale = this.detail.isonsale+''
  119. this.init()
  120. console.log(this.files,this.detail,'数据');
  121. uni.setNavigationBarTitle({
  122. title: '编辑商品'
  123. });
  124. })
  125. },
  126. async init () {
  127. let form
  128. if (this.detail.pricetype == '一口价') {
  129. form = [{
  130. key: "price",
  131. type: "text",
  132. inputmode:'digit',
  133. label: "价格(元/",
  134. isMust: true,//是否必填
  135. value: "",
  136. descript:'官方指导价:',
  137. },{
  138. key: "tag",
  139. type: "text",
  140. inputmode:'text',
  141. label: "标签",
  142. isMust: false,//是否必填
  143. value: "",
  144. paddingBottom:15,
  145. borderRadius:true,
  146. descript:'官方建议:'
  147. },{
  148. key: "isonsale",
  149. type: "radio",
  150. options:[{label:'上架',name:'1',marginRight:50},{label:'下架',name:'0'}],
  151. label: "状态",
  152. isMust: true,//是否必填
  153. value: "",
  154. }]
  155. } else {
  156. form = [{
  157. key: "price_rebate",
  158. type: "text",
  159. inputmode:'digit',
  160. label: "总部返利价(元/",
  161. isMust: true,//是否必填
  162. value: "",
  163. descript:'官方指导价:',
  164. },{
  165. key: "price_original",
  166. type: "text",
  167. inputmode:'digit',
  168. label: "原价(元/",
  169. isMust: true,//是否必填
  170. value: "",
  171. paddingBottom:15,
  172. descript:'官方指导价:',
  173. },{
  174. key: "price_store",
  175. type: "text",
  176. inputmode:'digit',
  177. label: "店面最低价(元/",
  178. isMust: true,//是否必填
  179. value: "",
  180. paddingBottom:15,
  181. descript:'官方指导价:',
  182. },{
  183. key: "price_deposit",
  184. type: "text",
  185. inputmode:'digit',
  186. label: "定金(元/",
  187. isMust: true,//是否必填
  188. value: "",
  189. paddingBottom:15,
  190. descript:'官方指导价:',
  191. },{
  192. key: "isonsale",
  193. type: "radio",
  194. options:[{label:'上架',name:'1',marginRight:50},{label:'下架',name:'0'}],
  195. label: "状态",
  196. isMust: true,//是否必填
  197. value: "",
  198. }]
  199. }
  200. form = form.map(v => {
  201. if (v.key == 'tag') v.descript = v.descript + this.detail.officialinfo[v.key]
  202. if (v.key != 'isonsale' && v.key != 'tag') {
  203. v.descript = v.descript + this.detail.officialinfo[v.key]
  204. v.label = v.label + this.detail.unitname + ')'
  205. }
  206. v.value = this.detail[v.key] || v.value
  207. return v
  208. })
  209. this.form = form
  210. console.log(this.form,'value');
  211. },
  212. },
  213. }
  214. </script>
  215. <style lang="scss">
  216. .swiper {
  217. width: 100vw;
  218. height: 377px;
  219. }
  220. .descript {
  221. font-weight: 400;
  222. font-size: 14px;
  223. color: #E3041F;
  224. padding-left: 10px;
  225. }
  226. .price-content {
  227. background: #ffffff;
  228. margin-top: 10px;
  229. .item-box {
  230. display: flex;
  231. align-content: center;
  232. align-items: center;
  233. padding: 15px 0 0 10px;
  234. .price-label {
  235. margin-right: 10px;
  236. color: #666666;
  237. }
  238. }
  239. }
  240. .head {
  241. position: relative;
  242. background: #fff;
  243. padding: 10px;
  244. box-sizing: border-box;
  245. margin-bottom: 10px;
  246. .name {
  247. width: 280px;
  248. height: 24px;
  249. line-height: 24px;
  250. font-family: Source Han Sans SC, Source Han Sans SC;
  251. font-weight: bold;
  252. font-size: 16px;
  253. color: #333333;
  254. margin-bottom: 10px;
  255. }
  256. text {
  257. font-weight: 400;
  258. font-size: 12px;
  259. color: #999999;
  260. }
  261. .model {
  262. margin-bottom: 5px;
  263. }
  264. }
  265. .footer {
  266. position: fixed;
  267. bottom: 0;
  268. width: 100vw;
  269. height: 65px;
  270. background: #FFFFFF;
  271. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  272. box-sizing: border-box;
  273. padding: 5px 10px;
  274. z-index: 5;
  275. display: flex;
  276. .add {
  277. display: flex;
  278. align-items: center;
  279. justify-content: center;
  280. width: 100%;
  281. height: 45px;
  282. background: #C30D23;
  283. border-radius: 5px;
  284. font-family: PingFang SC, PingFang SC;
  285. font-size: 14px;
  286. color: #FFFFFF;
  287. }
  288. .forbidden {
  289. opacity: .6;
  290. }
  291. }
  292. </style>