third-apply.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="person-msg">
  3. <Form ref="thirdForm" :model="form" :rules="rules" :label-width="140">
  4. <h4>基础信息</h4>
  5. <FormItem prop="storeName" label="店铺名称">
  6. <Input
  7. type="text"
  8. v-model="form.storeName"
  9. placeholder="请填写店铺名称"
  10. />
  11. </FormItem>
  12. <FormItem prop="storeLogo" label="店铺logo">
  13. <Upload
  14. ref="uploadLogo"
  15. :show-upload-list="false"
  16. :on-success="handleSuccess"
  17. :format="['jpg', 'jpeg', 'png', 'gif']"
  18. :max-size="2048"
  19. :before-upload="beforeUpload"
  20. :on-format-error="handleFormatError"
  21. :on-exceeded-size="handleMaxSize"
  22. :on-error="uploadErr"
  23. multiple
  24. :action="action"
  25. :headers="accessToken"
  26. >
  27. <Button type="info" :loading="uploadLoading">上传logo</Button>
  28. </Upload>
  29. <div class="describe">请压缩图片在2M以内,格式为gif,jpg,png</div>
  30. <div
  31. class="img-list"
  32. v-for="(item, index) in form.storeLogo"
  33. :key="index"
  34. >
  35. <img :src="item" width="100" height="" alt="" />
  36. <div class="cover">
  37. <Icon
  38. type="ios-eye-outline"
  39. @click.native="handleView(item)"
  40. ></Icon>
  41. <Icon
  42. type="ios-trash-outline"
  43. @click.native="handleRemove(index, 'storeLogo')"
  44. ></Icon>
  45. </div>
  46. </div>
  47. </FormItem>
  48. <FormItem prop="goodsManagementCategory" label="店铺经营类目">
  49. <Select
  50. v-model="form.goodsManagementCategory"
  51. multiple
  52. style="width: 300px"
  53. >
  54. <Option
  55. v-for="item in categoryList"
  56. :value="item.id"
  57. :key="item.id"
  58. >{{ item.name }}</Option
  59. >
  60. </Select>
  61. </FormItem>
  62. <FormItem prop="storeCenter" label="经纬度">
  63. <Input
  64. type="text"
  65. v-model="form.storeCenter"
  66. readonly
  67. placeholder="点击右侧按钮选择店铺位置"
  68. />
  69. <Button
  70. icon="ios-locate-outline"
  71. @click="$refs.liliMap.showMap = true"
  72. ></Button>
  73. </FormItem>
  74. <FormItem prop="storeDesc" label="店铺简介">
  75. <Input
  76. type="textarea"
  77. v-model="form.storeDesc"
  78. maxlength="300"
  79. show-word-limit
  80. :rows="4"
  81. placeholder="请输入店铺简介"
  82. />
  83. </FormItem>
  84. <FormItem>
  85. <Button @click="$emit('change', 1)">返回</Button>
  86. <Button type="primary" :loading="loading" @click="next"
  87. >提交平台审核</Button
  88. >
  89. </FormItem>
  90. </Form>
  91. <Modal title="View Image" v-model="visible">
  92. <img :src="previewPicture" v-if="visible" style="width: 100%" />
  93. </Modal>
  94. <lili-map ref="liliMap" @getAddress="getAddress" :useApi="false"></lili-map>
  95. </div>
  96. </template>
  97. <script>
  98. import { applyThird } from '@/api/shopentry';
  99. import { getCategory } from '@/api/goods';
  100. import Map from '@/components/map/index';
  101. import storage from '@/plugins/storage';
  102. import { commonUrl } from '@/plugins/request.js';
  103. export default {
  104. props: {
  105. content: {
  106. default: {},
  107. type: Object
  108. }
  109. },
  110. components: { liliMap: Map },
  111. data () {
  112. return {
  113. loading: false, // 加载状态
  114. uploadLoading: false, // 上传加载状态
  115. action: commonUrl + '/common/upload/file', // 上传地址
  116. accessToken: {}, // 验证token
  117. previewPicture: '', // 预览图片
  118. visible: false, // 图片预览
  119. form: { // 表单数据
  120. storeLogo: []
  121. },
  122. rules: { // 验证规则
  123. goodsManagementCategory: [
  124. { required: true, message: '请选择店铺经营类目' }
  125. ],
  126. storeName: [{ required: true, message: '请填写店铺名称' }],
  127. storeLogo: [{ required: true, message: '请上传店铺logo' }],
  128. storeDesc: [{ required: true, message: '请填写店铺简介' }],
  129. storeCenter: [{ required: true, message: '请选择店铺位置' }]
  130. },
  131. categoryList: [] // 分类数据
  132. };
  133. },
  134. methods: {
  135. next () {
  136. this.$refs.thirdForm.validate((valid) => {
  137. if (valid) {
  138. this.loading = true;
  139. let params = JSON.parse(JSON.stringify(this.form));
  140. params.storeLogo = this.form.storeLogo.toString();
  141. params.goodsManagementCategory = this.form.goodsManagementCategory.toString();
  142. applyThird(params)
  143. .then((res) => {
  144. this.loading = false;
  145. if (res.success) this.$emit('change', 3);
  146. })
  147. .catch(() => {
  148. this.loading = false;
  149. });
  150. } else {
  151. console.log('error');
  152. }
  153. });
  154. },
  155. beforeUpload () {
  156. this.uploadLoading = true;
  157. },
  158. handleSuccess (res, file) {
  159. this.uploadLoading = false;
  160. this.form.storeLogo.push(res.result);
  161. },
  162. handleFormatError (file) {
  163. this.uploadLoading = false;
  164. this.$Notice.warning({
  165. title: 'The file format is incorrect',
  166. desc: '上传文件格式不正确'
  167. });
  168. },
  169. handleMaxSize (file) {
  170. this.uploadLoading = false;
  171. this.$Notice.warning({
  172. title: 'Exceeding file size limit',
  173. desc: '文件大小不能超过2M'
  174. })
  175. },
  176. uploadErr () {
  177. this.uploadLoading = false;
  178. },
  179. handleView (item) {
  180. this.previewPicture = item;
  181. this.visible = true;
  182. },
  183. handleRemove (index, listName) {
  184. this.form[listName].splice(index, 1);
  185. },
  186. getAddress (item) {
  187. console.log(item);
  188. this.$set(
  189. this.form,
  190. 'storeCenter',
  191. item.position.lng + ',' + item.position.lat
  192. );
  193. },
  194. getCategoryList () {
  195. getCategory(0).then((res) => {
  196. if (res.success) this.categoryList = res.result;
  197. });
  198. }
  199. },
  200. mounted () {
  201. this.accessToken.accessToken = storage.getItem('accessToken');
  202. this.getCategoryList();
  203. if (this.content != {}) {
  204. this.form = JSON.parse(JSON.stringify(this.content));
  205. if (this.form.storeLogo) {
  206. this.form.storeLogo = this.content.storeLogo.split(',');
  207. this.form.goodsManagementCategory = this.content.goodsManagementCategory.split(
  208. ','
  209. );
  210. } else {
  211. this.form.storeLogo = [];
  212. }
  213. this.$forceUpdate();
  214. }
  215. }
  216. };
  217. </script>
  218. <style lang="scss" scoped>
  219. h4 {
  220. margin-bottom: 10px;
  221. padding: 0 10px;
  222. border: 1px solid #ddd;
  223. background-color: #f8f8f8;
  224. font-weight: bold;
  225. color: #333;
  226. font-size: 14px;
  227. line-height: 40px;
  228. text-align: left;
  229. }
  230. .ivu-input-wrapper {
  231. width: 300px;
  232. }
  233. .img-list {
  234. display: inline-block;
  235. margin: 10px;
  236. width: 100px;
  237. height: auto;
  238. position: relative;
  239. .cover {
  240. display: none;
  241. position: absolute;
  242. top: 0;
  243. bottom: 0;
  244. left: 0;
  245. right: 0;
  246. background: rgba(0, 0, 0, 0.6);
  247. width: inherit;
  248. height: inherit;
  249. align-items: center;
  250. justify-content: space-around;
  251. i {
  252. color: #fff;
  253. font-size: 30px;
  254. cursor: pointer;
  255. }
  256. }
  257. &:hover .cover {
  258. display: flex;
  259. }
  260. }
  261. .describe {
  262. font-size: 12px;
  263. color: #999;
  264. }
  265. </style>