index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <view class="help">
  3. <!-- <view class="posi" @click="changePosi">
  4. <text><text class="star">*</text>位置:
  5. {{form.province_name}}{{form.city_name}}{{form.area_name}}{{form.street_name}}</text>
  6. </view> -->
  7. <!-- <view class="form" @click="changePosi">
  8. <view class="title">
  9. 位置<text class="star">*</text>
  10. <u-icon name="arrow-right" class="icon"></u-icon>
  11. </view>
  12. <view class="input">
  13. <text class="posi">
  14. {{form.province_name}}{{form.city_name}}{{form.area_name}}{{form.street_name}}</text>
  15. </view>
  16. </view> -->
  17. <view class="form">
  18. <view class="title">
  19. 省市县区<text class="star">*</text>
  20. </view>
  21. <view class="input" @click="changePosi">
  22. <text>
  23. {{form.province_name}}{{form.city_name}}{{form.area_name}}{{form.street_name}}</text>
  24. </view>
  25. </view>
  26. <view class="form">
  27. <view class="title">
  28. 详细地址<text class="star">*</text>
  29. </view>
  30. <view class="input">
  31. <u-input v-model="form.address" type="textarea" height="50" />
  32. </view>
  33. <view class="address-icon" @click="changePosi">
  34. <u-icon name="map-fill" color='#10C08C' size="32"></u-icon>
  35. <view>定位</view>
  36. </view>
  37. </view>
  38. <view class="form">
  39. <view class="title">
  40. 名称 <text class="star">*</text>
  41. </view>
  42. <view class="input">
  43. <u-input v-model="form.name" type="textarea" height="50" />
  44. </view>
  45. </view>
  46. <view class="form">
  47. <view class="title">
  48. 工作时间<text class="star">*</text>
  49. </view>
  50. <view class="input">
  51. <u-input v-model="form.time" type="textarea" height="50" />
  52. </view>
  53. </view>
  54. <view class="form" style="border: none;">
  55. <view class="title">
  56. 上传图片
  57. </view>
  58. <view class="title" style="flex: 1;">
  59. <text style="font-size: 12px;color: #B5B5B5">请上传带有时间公告的图片</text>
  60. </view>
  61. </view>
  62. <view class="form" style="border: none;">
  63. <view class="input">
  64. <u-upload ref="uUpload" :action="action" :auto-upload="true" :form-data='imageDate' :fileList="fileList"
  65. :multiple="false" @on-success='uploadSuccess' @on-error="uploadError" @on-delete='deleteImage'>
  66. </u-upload>
  67. </view>
  68. </view>
  69. <!-- <view class="form">
  70. <view class="title">
  71. 备注:
  72. </view>
  73. <view class="input">
  74. <u-input v-model="value" type="textarea" :border="true" height="200" />
  75. </view>
  76. </view> -->
  77. <view class="tip_1">
  78. 谢谢您,您提交的信息能帮助很多人!
  79. </view>
  80. <view class="submit" v-if="type==0" @click="submit">
  81. 提交信息
  82. </view>
  83. <view class="submit" v-if="type==1" @click="save">
  84. 保存修改
  85. </view>
  86. <view class="tip_2">
  87. 注意:如果恶意上传无用信息,将永久封禁账号
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. export default {
  93. data() {
  94. return {
  95. form: {
  96. name: '',
  97. cover: '',
  98. address: '',
  99. time: '',
  100. lat: '',
  101. lng: '',
  102. province_name: '',
  103. city_name: '',
  104. area_name: '',
  105. street_name: '',
  106. },
  107. action: '', //封面图上传地址
  108. imageDate: {
  109. type: 'point_cover',
  110. file_type: 'img'
  111. }, //上传图片携带参数
  112. fileList: [],
  113. lng: '',
  114. lat: '',
  115. first: true,
  116. type: 0, //添加 1修改
  117. isAuth: false,
  118. }
  119. },
  120. onLoad(options) {
  121. this.action = this.$u.http.config.baseUrl + '/base/common/upload'
  122. if (options.slug) {
  123. this.getDetail(options.slug)
  124. this.type = 1
  125. } else {
  126. this.type = 0
  127. }
  128. uni.getLocation({
  129. type: 'wgs84',
  130. success: (res) => {
  131. console.log(res, 'pppppp-----------')
  132. this.lat = res.latitude
  133. this.lng = res.longitude
  134. this.form.lat = res.latitude
  135. this.form.lng = res.longitude
  136. this.getLocation(res)
  137. }
  138. })
  139. // this.$u.post('/base/common/upload', {
  140. // type: 'point_cover',
  141. // file_type: 'img'
  142. // }).then(res => {
  143. // console.log(res, '详情')
  144. // this.form = res.data.point
  145. // })
  146. },
  147. onShow() {
  148. // let that = this
  149. // this.form.name = ''
  150. // this.form.cover = ''
  151. // this.form.time = ''
  152. },
  153. onTabItemTap() {
  154. this.form.name = ''
  155. this.form.cover = ''
  156. this.form.time = ''
  157. },
  158. methods: {
  159. getDetail(slug) {
  160. this.$u.get('/qunali/info', {
  161. slug: slug
  162. }).then(res => {
  163. console.log(res, '详情')
  164. this.form = res.data.point
  165. })
  166. },
  167. //获取位置
  168. getLocation(res) {
  169. this.$u.get('/qunali/geocoder', {
  170. lat: res.latitude,
  171. lng: res.longitude
  172. }).then(res => {
  173. this.form.province_name = res.data.province
  174. this.form.city_name = res.data.city
  175. this.form.area_name = res.data.area
  176. this.form.street_name = res.data.street
  177. this.form.address = res.data.address ? res.data.address : ''
  178. })
  179. },
  180. //选择位置
  181. changePosi() {
  182. uni.chooseLocation({
  183. latitude: this.form.lat,
  184. longitude: this.form.lng,
  185. success: (res) => {
  186. console.log(res, 'ppppp--------')
  187. let data = {
  188. latitude: res.latitude,
  189. longitude: res.longitude
  190. }
  191. this.form.lat = res.latitude
  192. this.form.lng = res.longitude
  193. this.getLocation(data)
  194. }
  195. })
  196. },
  197. uploadSuccess(data) {
  198. this.form.cover = data.data.path
  199. this.uploadImage = data.data.url
  200. console.log(this.fileList, 'filelist')
  201. },
  202. uploadError(data) {
  203. console.log(data, 'p')
  204. this.fileList = []
  205. this.uploadImage = ''
  206. this.form.cover = ''
  207. },
  208. deleteImage() {
  209. console.log('pppp')
  210. this.uploadImage = ''
  211. this.form.cover = ''
  212. },
  213. getUserProfile(e) {
  214. // 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
  215. // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
  216. wx.getUserProfile({
  217. desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  218. success: (res) => {
  219. let userInfo = res.userInfo
  220. this.tongBu(userInfo)
  221. }
  222. })
  223. },
  224. //同步
  225. tongBu(data) {
  226. this.$u.post('/base/auth/weapp/user-info-sync', data).then(res => {
  227. console.log(res, 'opopop')
  228. this.$u.vuex('vuex_user', res.data);
  229. })
  230. },
  231. //提交信息
  232. submit() {
  233. let user = this.vuex_user.is_sync_info
  234. if (user == 0) {
  235. this.getUserProfile()
  236. return
  237. }
  238. console.log((!this.form.name), 'form')
  239. if (!this.form.address) {
  240. uni.showToast({
  241. title: '请填写详细地址!',
  242. icon: 'none'
  243. })
  244. return
  245. }
  246. if (!this.form.name) {
  247. uni.showToast({
  248. title: '请填写名称!',
  249. icon: 'none'
  250. })
  251. return
  252. }
  253. if (!this.form.time) {
  254. uni.showToast({
  255. title: '请填写工作时间!',
  256. icon: 'none'
  257. })
  258. return
  259. }
  260. this.$u.post('/qunali/point', this.form).then(res => {
  261. uni.reLaunch({
  262. url: '../index/index'
  263. })
  264. })
  265. },
  266. //保存
  267. save() {
  268. let user = this.vuex_user.is_sync_info
  269. if (user == 0) {
  270. this.getUserProfile()
  271. return
  272. }
  273. if (!this.form.address) {
  274. uni.showToast({
  275. title: '请填写详细地址!',
  276. icon: 'none'
  277. })
  278. return
  279. }
  280. if (!this.form.name) {
  281. uni.showToast({
  282. title: '请填写名称!',
  283. icon: 'none'
  284. })
  285. return
  286. }
  287. if (!this.form.time) {
  288. uni.showToast({
  289. title: '请填写工作时间!',
  290. icon: 'none'
  291. })
  292. return
  293. }
  294. this.$u.post('/qunali/version', this.form).then(res => {
  295. uni.reLaunch({
  296. url: '../index/index'
  297. })
  298. })
  299. }
  300. }
  301. }
  302. </script>
  303. <style lang="scss" scoped>
  304. ::v-deep .u-upload {
  305. height: 114px !important;
  306. width: 114px !important;
  307. overflow: hidden !important;
  308. }
  309. .icon {
  310. float: right;
  311. }
  312. .star {
  313. color: red;
  314. }
  315. .help {
  316. padding: 5px 20px 70px;
  317. }
  318. .posi {
  319. display: flex;
  320. justify-content: space-between;
  321. color: #10C08C;
  322. }
  323. .form {
  324. margin-top: 10px;
  325. padding-bottom: 10px;
  326. display: flex;
  327. border-bottom: 1px solid #EEEEEE;
  328. align-items: center;
  329. .title {
  330. display: flex;
  331. align-items: center;
  332. flex: 0 0 80px;
  333. font-size: 16px;
  334. color: #000000;
  335. // margin-top: 5px;
  336. }
  337. .address-icon {
  338. text-align: center;
  339. font-size: 12px;
  340. color: #10C08C;
  341. margin-top: 5px;
  342. padding-left: 5px;
  343. }
  344. .input {
  345. flex: 1;
  346. }
  347. }
  348. ::v-deep {
  349. .u-input {
  350. padding-top: 5px !important;
  351. border: none !important;
  352. }
  353. }
  354. .submit {
  355. height: 52px;
  356. line-height: 52px;
  357. text-align: center;
  358. background: #10C08C;
  359. border-radius: 23px;
  360. font-size: 18px;
  361. margin-top: 15px;
  362. color: #FFFFFF;
  363. border: 1px solid #10C08C;
  364. }
  365. .tip_1 {
  366. font-size: 16px;
  367. color: #10C08C;
  368. margin-top: 34px;
  369. text-align: center;
  370. }
  371. .tip_2 {
  372. color: #757373;
  373. font-size: 12px;
  374. text-align: center;
  375. margin-top: 22px;
  376. }
  377. </style>