index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <view>
  3. <view class="hehuo_view" v-if="XCXIsSelect == '是'">
  4. <image src="../../static/images/my/hezuobg.png"></image>
  5. <view class="text_view">
  6. <view class="item_view">
  7. <view class="item_title">意向代理城市</view>
  8. <input @click="goCity" type="text" disabled v-model="city" placeholder="请输入代理城市" />
  9. <view class="xian"></view>
  10. </view>
  11. <view class="item_view">
  12. <view class="item_title">姓名</view>
  13. <input type="text" v-model="userName" placeholder="请输入姓名" />
  14. <view class="xian"></view>
  15. </view>
  16. <view class="item_view">
  17. <view class="item_title">联系电话</view>
  18. <input type="number" v-model="phone" maxlength="11" placeholder="请输入联系电话" />
  19. <view class="xian"></view>
  20. </view>
  21. <view class="item_view">
  22. <view class="item_title">年龄</view>
  23. <input type="number" v-model="age" maxlength="11" placeholder="请输入年龄" />
  24. <view class="xian"></view>
  25. </view>
  26. <view class="item_view">
  27. <view class="item_title">头像上传</view>
  28. <view class="flex" style="overflow: hidden; flex-direction: initial">
  29. <view v-if="headImg.length">
  30. <view class="margin-top flex margin-right-sm">
  31. <view class="flex" style="width: 150upx; height: 150upx; margin-right: 10rpx; position: relative">
  32. <image :src="headImg" style="width: 100%; height: 100%"></image>
  33. <view style="z-index: 9; position: absolute; top: -15rpx; right: -15rpx" @click="headImgremove(index)">
  34. <u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="margin-top" @click="addImage()" v-if="headImg.length <= 0">
  40. <view style="width: 150upx; height: 150upx; background: #f5f5f5" class="flex justify-center align-center">
  41. <view>
  42. <view class="text-center">
  43. <image src="../../static/images/my/add.png" style="width: 54upx; height: 47upx; position: relative"></image>
  44. </view>
  45. <view class="text-center text-xs margin-top-xs">上传图片</view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- <view class="audit_message" v-if="auditContent != '' && bb == 3">拒绝原因:{{auditContent}}</view> -->
  52. <view class="save_btn" @tap="save" v-if="bb != 0">提交申请</view>
  53. <!-- <view class="save_btn" v-if="status == 0">审核中</view> -->
  54. </view>
  55. </view>
  56. <!-- 用于图片压缩的canvas画布 -->
  57. <canvas
  58. :style="{
  59. width: cw + 'px',
  60. height: cw + 'px',
  61. position: 'absolute',
  62. zIndex: -1,
  63. left: '-10000rpx',
  64. top: '-10000rpx'
  65. }"
  66. canvas-id="zipCanvas"
  67. ></canvas>
  68. <!--画布结束-->
  69. </view>
  70. </template>
  71. <script>
  72. import configdata from '@/common/config.js'
  73. import getLessLimitSizeImage from '@/utils/imageCompress.js'
  74. export default {
  75. data() {
  76. return {
  77. hotCitys: ['杭州', '天津', '北京', '上海', '深圳', '广州', '成都', '重庆', '厦门'],
  78. locationValue: '正在定位...',
  79. // auditContent: '',
  80. city: '',
  81. money: '',
  82. teamNumber: '',
  83. userName: '',
  84. phone: '',
  85. age: '',
  86. headImg: [],
  87. bb: true,
  88. XCXIsSelect: '是',
  89. //画板边长默认是屏幕宽度,正方形画布
  90. cw: uni.getSystemInfoSync().windowWidth
  91. }
  92. },
  93. onLoad() {
  94. this.XCXIsSelect = this.$queue.getData('XCXIsSelect')
  95. if (this.XCXIsSelect == '否') {
  96. uni.setNavigationBarTitle({
  97. title: '隐私政策'
  98. })
  99. } else {
  100. uni.setNavigationBarTitle({
  101. title: '骑手招募'
  102. })
  103. }
  104. this.getChannel()
  105. },
  106. methods: {
  107. // 头像删除
  108. headImgremove(index) {
  109. this.headImg = ''
  110. },
  111. getChannel() {
  112. let userId = this.$queue.getData('userId')
  113. let data = {
  114. userId: userId
  115. }
  116. this.$Request.getT('/app/artificer/selectAgencyById', data).then((res) => {
  117. if (res.code == 0) {
  118. if (res.data == null) {
  119. this.bb = 1
  120. } else {
  121. this.bb = res.data.status
  122. this.city = res.data.city
  123. this.age = res.data.age
  124. this.headImg = res.data.img
  125. this.userName = res.data.name
  126. this.phone = res.data.phone
  127. }
  128. console.log(this.bb)
  129. // this.auditContent = res.data.auditContent;
  130. }
  131. })
  132. },
  133. //获取省市区
  134. Getcity(latitude, longitude) {
  135. this.$Request
  136. .get('/app/Login/selectCity', {
  137. lat: latitude,
  138. lng: longitude
  139. })
  140. .then((res) => {
  141. console.log(res)
  142. this.city = res.data.city
  143. console.log(this.address)
  144. })
  145. },
  146. goCity() {
  147. let that = this
  148. uni.chooseLocation({
  149. success: function (res) {
  150. console.log('位置名称:' + res.name)
  151. console.log('详细地址:' + res.address)
  152. console.log('纬度:' + res.latitude)
  153. console.log('经度:' + res.longitude)
  154. // that.city = res.address || '郑州'
  155. that.Getcity(res.latitude, res.longitude)
  156. }
  157. })
  158. // uni.getLocation({
  159. // type: 'gcj02',
  160. // geocode: true,
  161. // success: function(res) {
  162. // console.log('当前位置:' + res.address.city);
  163. // that.city = res.address.city || '郑州'
  164. // }
  165. // });
  166. },
  167. save() {
  168. // let isStudent = this.$queue.getData("isStudent");
  169. // if (isStudent != 2) {
  170. // uni.showModal({
  171. // title: '温馨提示',
  172. // content: '您还没有进行实名认证,请认证完成之后再来操作吧!',
  173. // showCancel: true,
  174. // cancelText: '取消',
  175. // confirmText: '确认',
  176. // success: res => {
  177. // if (res.confirm) {
  178. // uni.navigateTo({
  179. // url: '/offlinetask/pages/public/authentication'
  180. // });
  181. // }
  182. // }
  183. // });
  184. // return;
  185. // }
  186. // this.form.headImg = this.headImg
  187. // this.headImg = this.headImg.toString();
  188. if (this.city === '') {
  189. this.$queue.showToast('请输入代理城市')
  190. return
  191. }
  192. if (this.userName === '') {
  193. this.$queue.showToast('请输入姓名')
  194. return
  195. }
  196. if (this.phone === '' || this.phone.length != 11) {
  197. this.$queue.showToast('请输入正确的手机号!')
  198. return
  199. }
  200. if (this.age === '') {
  201. this.$queue.showToast('请输入年龄')
  202. return
  203. }
  204. if (this.headImg == '') {
  205. this.$queue.showToast('请上传头像')
  206. return
  207. }
  208. let userId = this.$queue.getData('userId')
  209. let data = {
  210. userId: userId,
  211. name: this.userName,
  212. phone: this.phone,
  213. age: this.age,
  214. city: this.city,
  215. img: this.headImg
  216. }
  217. this.$Request.postJson('/app/artificer/insertAgency', data).then((res) => {
  218. if (res.code == 0) {
  219. uni.hideLoading()
  220. this.$queue.showToast('提交成功!')
  221. setTimeout((d) => {
  222. uni.navigateBack()
  223. }, 1000)
  224. } else {
  225. uni.hideLoading()
  226. this.$queue.showToast(res.msg)
  227. }
  228. })
  229. },
  230. addImage() {
  231. let that = this
  232. uni.chooseImage({
  233. count: 1,
  234. sourceType: ['album', 'camera'],
  235. success: (res) => {
  236. for (let i = 0; i < 1; i++) {
  237. //这里的id和页面中写的html代码的canvas的id要一致
  238. let canvasId = 'zipCanvas'
  239. //原图的路径
  240. let imagePath = res.tempFiles[i].path
  241. //大小限制
  242. let limitSize = 1024 * 2
  243. //初始绘画区域是画布自身的宽度也就是屏幕宽度
  244. let drawWidth = uni.getSystemInfoSync().windowWidth
  245. let that = this
  246. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
  247. uni.showLoading({
  248. title: '上传中'
  249. })
  250. uni.uploadFile({
  251. url: that.config('APIHOST1') + '/alioss/upload',
  252. filePath: resPath,
  253. name: 'file',
  254. success: (uploadFileRes) => {
  255. console.log(uploadFileRes.data)
  256. that.headImg = JSON.parse(uploadFileRes.data).data
  257. console.log(that.headImg)
  258. uni.hideLoading()
  259. },
  260. fail: () => {
  261. uni.showToast({
  262. title: '上传失败',
  263. icon: 'error'
  264. })
  265. }
  266. })
  267. })
  268. }
  269. }
  270. })
  271. },
  272. config: function (name) {
  273. var info = null
  274. if (name) {
  275. var name2 = name.split('.') //字符分割
  276. if (name2.length > 1) {
  277. info = configdata[name2[0]][name2[1]] || null
  278. } else {
  279. info = configdata[name] || null
  280. }
  281. if (info == null) {
  282. let web_config = cache.get('web_config')
  283. if (web_config) {
  284. if (name2.length > 1) {
  285. info = web_config[name2[0]][name2[1]] || null
  286. } else {
  287. info = web_config[name] || null
  288. }
  289. }
  290. }
  291. }
  292. return info
  293. }
  294. }
  295. }
  296. </script>
  297. <style lang="less">
  298. // @import '../../static/less/index.less';
  299. // @import '../../static/css/index.css';
  300. .hehuo_view {
  301. width: 750rpx;
  302. height: 1830upx;
  303. image {
  304. width: 750rpx;
  305. height: 1830upx;
  306. background-size: 100%;
  307. position: absolute;
  308. }
  309. .text_view {
  310. position: absolute;
  311. z-index: 1;
  312. width: 84%;
  313. margin: 660rpx 50rpx 30rpx;
  314. .audit_message {
  315. color: red;
  316. width: 650rpx;
  317. height: 50rpx;
  318. margin-top: 50rpx;
  319. }
  320. .save_btn {
  321. width: 650rpx;
  322. height: 88rpx;
  323. background: #ffffff;
  324. border-radius: 10rpx;
  325. text-align: center;
  326. line-height: 88rpx;
  327. /* #ifdef MP-WEIXIN */
  328. margin-top: 150rpx;
  329. /* #endif */
  330. /* #ifdef H5 */
  331. margin-top: 100rpx;
  332. /* #endif */
  333. /* #ifdef APP-PLUS */
  334. margin-top: 180rpx;
  335. /* #endif */
  336. }
  337. .save_btn1 {
  338. width: 650rpx;
  339. height: 88rpx;
  340. background: #ffffff;
  341. border-radius: 10rpx;
  342. margin-top: 100rpx;
  343. text-align: center;
  344. line-height: 88rpx;
  345. }
  346. .item_view {
  347. margin-top: 30rpx;
  348. .item_title {
  349. font-size: 28rpx;
  350. font-family: PingFang SC Heavy, PingFang SC Heavy-Heavy;
  351. font-weight: 800;
  352. color: #333333;
  353. }
  354. input {
  355. margin-top: 20rpx;
  356. height: 40rpx;
  357. font-size: 24rpx;
  358. font-family: PingFang SC Regular, PingFang SC Regular-Regular;
  359. font-weight: 400;
  360. color: #333333;
  361. }
  362. .xian {
  363. width: 630rpx;
  364. height: 1rpx;
  365. border: 1rpx solid #77d7b0;
  366. margin-top: 10rpx;
  367. }
  368. }
  369. }
  370. }
  371. </style>