index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <view>
  3. <view class="result fail" v-if="auditStatus == 2">
  4. <view class="ddflex"><image src="../static/images/cancel.png"></image>审核不通过</view>
  5. <text v-if="auditContent">不通过原因:{{auditContent}}</text>
  6. </view>
  7. <view class="con">
  8. <view class="title">{{opt.id?'修改团队信息':'创建团队'}}</view>
  9. <view class="tits">团队名称</view>
  10. <input v-model="title" placeholder="请输入团队名称 (10字内)" placeholder-class="placeholder" class="ipt" />
  11. <view class="tits">团队简介</view>
  12. <textarea v-model="description" placeholder="请输入团队简介" placeholder-class="placeholder" class="text"></textarea>
  13. <view class="tits">团队头像</view>
  14. <view class="imgbox ddflex">
  15. <view class="imgs" v-for="(item, index) in zhiPicUrls" :key="index">
  16. <image :src="item" class="img" @tap="previewImg(zhiPicUrls, index)" mode="aspectFill"></image>
  17. <image src="../static/images/close.png" class="del" @tap="cleanimages(index)"></image>
  18. </view>
  19. <view class="upload ddflex" @click="uploadImgs" v-if="zhiPicUrls.length < 1"><image src="../static/images/upload.png"></image></view>
  20. </view>
  21. <view class="other">
  22. <view class="li ddflex" @click="chooseLocation">
  23. <image src="../static/images/tj_wzico.png" class="o-ico"></image>
  24. <view class="fflex">位置</view>
  25. <view class="sel-ht" v-if="location">{{location.poiName}}</view>
  26. <image src="../static/images/rico.png" class="rico"></image>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="loca">
  31. <scroll-view scroll-x="true" class="locas">
  32. <view :class="'lis'+(poiIndex == index ? ' active':'')" @click="checkLocation(item,index)" v-for="(item,index) in poiList" :key="index">{{item.title}}</view>
  33. </scroll-view>
  34. </view>
  35. <view style="height: 160rpx"></view>
  36. <view class="btn" @click="submit()">{{opt.id?'保存修改':'创建队伍'}}</view>
  37. </view>
  38. </template>
  39. <script>
  40. const app = getApp();
  41. const api = require('../../utils/api.js');
  42. const req = require('../../utils/request.js');
  43. const QQMapWX = require("../../utils/qqmap.js");
  44. export default {
  45. data() {
  46. return {
  47. opt: {},
  48. zhiPicUrls: [],
  49. title: '',
  50. description: '',
  51. location: {},
  52. poiIndex: -1,
  53. poiList: [],
  54. auditStatus: '',//审核状态
  55. auditContent: '',//失败原因
  56. };
  57. },
  58. onLoad(options) {
  59. this.opt = options;
  60. if(options.id){
  61. this.getTeamInfo();
  62. uni.setNavigationBarTitle({
  63. title: '修改团队信息'
  64. })
  65. }
  66. QQMapWX.initMap();
  67. let location = {
  68. latitude: req.getStorage('loctionAddressMap').location.lat,
  69. longitude: req.getStorage('loctionAddressMap').location.lng
  70. }
  71. QQMapWX.reverseGeocoder(location, data => {
  72. this.poiList = data.pois;
  73. });
  74. },
  75. methods: {
  76. getTeamInfo(){
  77. req.getRequest(api.user_team_info+this.opt.id,{},data=>{
  78. this.title = data.title;
  79. this.description = data.description;
  80. this.zhiPicUrls[0] = data.url;
  81. this.auditStatus = data.auditStatus;
  82. this.auditContent = data.auditContent;
  83. this.location = {
  84. poiName: data.poiName,
  85. poiAddress: data.poiAddress,
  86. poiLongitude: data.poiLongitude,
  87. poiLatitude: data.poiLatitude,
  88. poiRegionalism: data.poiRegionalism
  89. }
  90. })
  91. },
  92. uploadImgs() {
  93. let that = this;
  94. uni.chooseImage({
  95. count: that.picCount - that.zhiPicUrls.length,
  96. sizeType: ['original', 'compressed'],
  97. sourceType: ['album', 'camera'],
  98. success: function({ tempFilePaths }) {
  99. uni.showLoading({
  100. title: '上传中'
  101. });
  102. var promise = Promise.all(
  103. tempFilePaths.map(tempFilePath => {
  104. return new Promise(function(resolve, reject) {
  105. req.uploadFile('/api/upload', tempFilePath, res => {
  106. let picUrls = that.zhiPicUrls;
  107. that.zhiPicUrls = picUrls.concat(res.src);
  108. uni.hideLoading()
  109. });
  110. });
  111. })
  112. );
  113. promise
  114. .then(function(results) {
  115. console.log(results);
  116. })
  117. .catch(function(err) {
  118. console.log(err);
  119. });
  120. }
  121. });
  122. },
  123. //预览图片
  124. previewImg(picUrls, index) {
  125. //预览合同图片
  126. var src = picUrls[index];
  127. let imgs = picUrls;
  128. uni.previewImage({
  129. current: src, // 当前显示图片的http链接
  130. urls: imgs
  131. });
  132. },
  133. cleanimages(index) {
  134. // 删除图片
  135. let arr = this.zhiPicUrls;
  136. arr.splice(index, 1);
  137. this.zhiPicUrls = arr;
  138. },
  139. chooseLocation(){
  140. let that = this;
  141. uni.chooseLocation({//choosePoi不返回经纬度
  142. success: function (res) {
  143. console.log('位置名称:' , res);
  144. that.location = {
  145. poiName: res.name,
  146. poiAddress: res.address,
  147. poiLongitude: res.longitude,
  148. poiLatitude: res.latitude
  149. }
  150. that.reverseGeocoder(res);
  151. }
  152. });
  153. },
  154. reverseGeocoder(location) {
  155. QQMapWX.initMap();
  156. QQMapWX.reverseGeocoder(location, data => {
  157. this.location.poiRegionalism = data.ad_info.adcode.substring(0, 2) + "0000," + data.ad_info.adcode.substring(0, 4) +"00," + data.ad_info.adcode
  158. console.log('解析后的地址地址数据:', data,this.location.poiRegionalism);
  159. });
  160. },
  161. checkLocation(item,index){
  162. if(this.poiIndex == index) return false;
  163. this.poiIndex = index;
  164. this.location = {
  165. poiName: item.title,
  166. poiAddress: item.address,
  167. poiLongitude: item.location.lng,
  168. poiLatitude: item.location.lat,
  169. poiRegionalism: item.ad_info.adcode.substring(0, 2) + "0000," + item.ad_info.adcode.substring(0, 4) +"00," + item.ad_info.adcode
  170. }
  171. },
  172. submit() {
  173. var dataPream = {};
  174. if (!this.title) return req.msg('请输入团队名称');
  175. if (!this.description) return req.msg('请输入团队简介');
  176. if (this.zhiPicUrls.length == 0) return req.msg('请上传团队头像');
  177. dataPream.title = this.title;
  178. dataPream.description = this.description;
  179. //图片
  180. if (this.zhiPicUrls.length > 0) {
  181. dataPream.url = this.zhiPicUrls.join(',');
  182. }
  183. // 位置
  184. if(this.location&&this.location.poiName){
  185. dataPream.poiName = this.location.poiName;
  186. dataPream.poiAddress = this.location.poiAddress;
  187. dataPream.poiLongitude = this.location.poiLongitude;
  188. dataPream.poiLatitude = this.location.poiLatitude;
  189. dataPream.poiRegionalism = this.location.poiRegionalism
  190. }
  191. if(this.opt.id){
  192. dataPream.id = this.opt.id;
  193. if(this.auditStatus == 2){
  194. this.editTeam(dataPream)
  195. }else{
  196. req.msgConfirm('修改后团队需要重新审核,确认保存修改吗?',suc=>{
  197. this.editTeam(dataPream)
  198. })
  199. }
  200. }else{
  201. this.createTeam(dataPream)
  202. }
  203. },
  204. createTeam(dataPream){
  205. uni.showLoading({
  206. mask: true
  207. })
  208. req.postRequest(api.create_user_team, dataPream, data => {
  209. uni.hideLoading();
  210. req.alertMsg('团队创建成功,请耐心等待审核',suc=>{
  211. let pages = getCurrentPages(); //获取所有页面栈实例列表
  212. let prevPage = pages[pages.length - 2]; //上一页页面实例
  213. prevPage.$vm.isRefresh = true;
  214. uni.navigateBack();
  215. })
  216. });
  217. },
  218. editTeam(dataPream){
  219. uni.showLoading({
  220. mask: true
  221. })
  222. req.putRequest(api.create_user_team, dataPream, data => {
  223. uni.hideLoading();
  224. req.msg('团队修改成功');
  225. setTimeout(() => {
  226. uni.navigateBack();
  227. }, 1500);
  228. });
  229. }
  230. }
  231. };
  232. </script>
  233. <style>
  234. @import './index.css';
  235. </style>