index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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.qunCode = data.groupCode?data.groupCode:''
  93. this.location = {
  94. poiName: data.poiName,
  95. poiAddress: data.poiAddress,
  96. poiLongitude: data.poiLongitude,
  97. poiLatitude: data.poiLatitude,
  98. poiRegionalism: data.poiRegionalism
  99. }
  100. })
  101. },
  102. uploadImgs() {
  103. let that = this;
  104. uni.chooseImage({
  105. count: that.picCount - that.zhiPicUrls.length,
  106. sizeType: ['original', 'compressed'],
  107. sourceType: ['album', 'camera'],
  108. success: function({ tempFilePaths }) {
  109. uni.showLoading({
  110. title: '上传中'
  111. });
  112. var promise = Promise.all(
  113. tempFilePaths.map(tempFilePath => {
  114. return new Promise(function(resolve, reject) {
  115. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  116. let picUrls = that.zhiPicUrls;
  117. that.zhiPicUrls = picUrls.concat(res.src);
  118. resolve()
  119. });
  120. });
  121. })
  122. );
  123. promise
  124. .then(function(results) {
  125. console.log(results);
  126. uni.hideLoading()
  127. })
  128. .catch(function(err) {
  129. uni.hideLoading()
  130. console.log(err);
  131. });
  132. }
  133. });
  134. },
  135. uploadImgsCode() {
  136. let that = this;
  137. uni.chooseImage({
  138. count: 1,
  139. sizeType: ['original', 'compressed'],
  140. sourceType: ['album', 'camera'],
  141. success: function({ tempFilePaths }) {
  142. uni.showLoading({
  143. title: '上传中'
  144. });
  145. var promise = Promise.all(
  146. tempFilePaths.map(tempFilePath => {
  147. return new Promise(function(resolve, reject) {
  148. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  149. that.qunCode = res.src;
  150. resolve()
  151. });
  152. });
  153. })
  154. );
  155. promise
  156. .then(function(results) {
  157. uni.hideLoading()
  158. console.log(results);
  159. })
  160. .catch(function(err) {
  161. uni.hideLoading()
  162. console.log(err);
  163. });
  164. }
  165. });
  166. },
  167. //预览图片
  168. previewImg(picUrls, index) {
  169. //预览合同图片
  170. var src = picUrls[index];
  171. let imgs = picUrls;
  172. uni.previewImage({
  173. current: src, // 当前显示图片的http链接
  174. urls: imgs
  175. });
  176. },
  177. cleanimages(index) {
  178. // 删除图片
  179. let arr = this.zhiPicUrls;
  180. arr.splice(index, 1);
  181. this.zhiPicUrls = arr;
  182. },
  183. cleanCode() {
  184. // 删除图片
  185. this.qunCode = '';
  186. },
  187. chooseLocation(){
  188. let that = this;
  189. uni.chooseLocation({//choosePoi不返回经纬度
  190. success: function (res) {
  191. console.log('位置名称:' , res);
  192. that.location = {
  193. poiName: res.name,
  194. poiAddress: res.address,
  195. poiLongitude: res.longitude,
  196. poiLatitude: res.latitude
  197. }
  198. that.reverseGeocoder(res);
  199. }
  200. });
  201. },
  202. reverseGeocoder(location) {
  203. QQMapWX.initMap();
  204. QQMapWX.reverseGeocoder(location, data => {
  205. this.location.poiRegionalism = data.ad_info.adcode.substring(0, 2) + "0000," + data.ad_info.adcode.substring(0, 4) +"00," + data.ad_info.adcode
  206. console.log('解析后的地址地址数据:', data,this.location.poiRegionalism);
  207. });
  208. },
  209. checkLocation(item,index){
  210. if(this.poiIndex == index) return false;
  211. this.poiIndex = index;
  212. this.location = {
  213. poiName: item.title,
  214. poiAddress: item.address,
  215. poiLongitude: item.location.lng,
  216. poiLatitude: item.location.lat,
  217. poiRegionalism: item.ad_info.adcode.substring(0, 2) + "0000," + item.ad_info.adcode.substring(0, 4) +"00," + item.ad_info.adcode
  218. }
  219. },
  220. submit() {
  221. var dataPream = {};
  222. if (!this.title) return req.msg('请输入团队名称');
  223. if (!this.description) return req.msg('请输入团队简介');
  224. if (this.zhiPicUrls.length == 0) return req.msg('请上传团队头像');
  225. dataPream.title = this.title;
  226. dataPream.description = this.description;
  227. //图片
  228. if (this.zhiPicUrls.length > 0) {
  229. dataPream.url = this.zhiPicUrls.join(',');
  230. }
  231. // 群二维码
  232. if(this.qunCode){
  233. dataPream.groupCode = this.qunCode
  234. }
  235. // 位置
  236. if(this.location&&this.location.poiName){
  237. dataPream.poiName = this.location.poiName;
  238. dataPream.poiAddress = this.location.poiAddress;
  239. dataPream.poiLongitude = this.location.poiLongitude;
  240. dataPream.poiLatitude = this.location.poiLatitude;
  241. dataPream.poiRegionalism = this.location.poiRegionalism
  242. }
  243. if(this.opt.id){
  244. dataPream.id = this.opt.id;
  245. if(this.auditStatus == 2){
  246. this.editTeam(dataPream)
  247. }else{
  248. req.msgConfirm('修改后团队需要重新审核,确认保存修改吗?',suc=>{
  249. this.editTeam(dataPream)
  250. })
  251. }
  252. }else{
  253. this.createTeam(dataPream)
  254. }
  255. },
  256. createTeam(dataPream){
  257. uni.showLoading({
  258. mask: true
  259. })
  260. req.postRequest(api.create_user_team, dataPream, data => {
  261. uni.hideLoading();
  262. req.alertMsg('团队创建成功,请耐心等待审核',suc=>{
  263. let pages = getCurrentPages(); //获取所有页面栈实例列表
  264. let prevPage = pages[pages.length - 2]; //上一页页面实例
  265. prevPage.$vm.isRefresh = true;
  266. uni.navigateBack();
  267. })
  268. });
  269. },
  270. editTeam(dataPream){
  271. uni.showLoading({
  272. mask: true
  273. })
  274. req.putRequest(api.create_user_team, dataPream, data => {
  275. uni.hideLoading();
  276. req.msg('团队修改成功');
  277. setTimeout(() => {
  278. uni.navigateBack();
  279. }, 1500);
  280. });
  281. }
  282. }
  283. };
  284. </script>
  285. <style>
  286. @import './index.css';
  287. </style>