index.vue 8.4 KB

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