敢为人鲜小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

436 lines
12 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar :title="`${ !identity ? '团长申请' : '团长信息' }`" leftClick @leftClick="$utils.navigateBack" bgColor="#019245"
  5. color="#fff" />
  6. <!-- 顶部图片区域 -->
  7. <view class="banner" v-if="!identity">
  8. <image src="/static/image/红烧肉.webp" mode="aspectFill" class="banner-image"></image>
  9. </view>
  10. <view class="content-area">
  11. <uv-alert v-if="status != '-1'" fontSize="28rpx" :title="toastTitle" :show-icon="true" closable :type="toastType"
  12. :description="remark" />
  13. <!-- 送餐点照片上传区域 -->
  14. <view class="section-title">送餐点照片 </view>
  15. <view class="section-block">
  16. <view class="upload-container">
  17. <view class="upload-area" @tap="chooseImage" v-if="!formData.spotImage">
  18. <view class="plus">+</view>
  19. <view class="upload-text">添加图片</view>
  20. </view>
  21. <image v-else :src="formData.spotImage" mode="aspectFill" class="upload-area" @tap="chooseImage" />
  22. </view>
  23. </view>
  24. <!-- 送餐点信息填写区域 -->
  25. <view class="section-title">送餐点信息</view>
  26. <view class="section-block">
  27. <view class="form-item">
  28. <text class="label">送餐点名称</text>
  29. <input class="input" type="text" v-model="formData.spotName" placeholder="请输入送餐点名称"
  30. placeholder-class="placeholder" />
  31. </view>
  32. <view class="form-item">
  33. <text class="label">您的姓名</text>
  34. <input class="input" type="nickname" v-model="formData.name" placeholder="请输入您的姓名"
  35. placeholder-class="placeholder" />
  36. </view>
  37. <view class="form-item">
  38. <text class="label">联系手机号</text>
  39. <input class="input" type="number" v-model="formData.phone" placeholder="请输入您的手机号"
  40. placeholder-class="placeholder" />
  41. </view>
  42. <view class="form-item region-item" @click="regionSelect">
  43. <text class="label">所在地区</text>
  44. <text>{{ formData.area }}</text>
  45. <uv-icon name="arrow-right" color="#000" style="margin-left: 2rpx;" />
  46. </view>
  47. <view class="address-item">
  48. <text class="label">详细地址</text>
  49. <view class="address-box">
  50. <textarea class="address-input" v-model="formData.address" placeholder="请输入详细地址"
  51. placeholder-class="placeholder" />
  52. </view>
  53. </view>
  54. </view>
  55. <!-- 提交按钮 -->
  56. <view class="submit-btn" v-if="status != '1' || identity != 0" @tap="submitApplication">
  57. {{ buttonText }}
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import navbar from '@/components/base/navbar.vue'
  64. import shareConfig from '@/mixins/configList.js'
  65. import position from '@/utils/position.js'
  66. export default {
  67. components: {
  68. navbar
  69. },
  70. mixins: [shareConfig],
  71. data() {
  72. return {
  73. formData: {
  74. spotImage: '', // 上传的送餐点照片
  75. spotName: '', // 送餐点名称
  76. name: '', // 联系人姓名
  77. phone: '', // 联系电话
  78. area: '', // 所在地区
  79. address: '', // 详细地址
  80. latitude: '', // 纬度
  81. longitude: '' // 经度
  82. },
  83. identity: uni.getStorageSync('identity'),
  84. status: '-1', // 团长申请状态 -1 未提交 0 审核中 1 审核通过 2 审核不通过
  85. remark: '', // 审核不通过原因
  86. noBind: false // 是否未绑定团长
  87. }
  88. },
  89. methods: {
  90. // 选择图片
  91. chooseImage() {
  92. this.$Oss.ossUploadImage({
  93. compressed: true,
  94. success: (res) => {
  95. console.log('上传成功',res);
  96. this.formData.spotImage = ''
  97. this.formData.spotImage = res
  98. },
  99. fail: (res) => {
  100. console.log('上传失败',res);
  101. uni.showToast({
  102. title: `上传失败,${res.errMsg}`,
  103. icon: 'error'
  104. })
  105. }
  106. })
  107. },
  108. // 显示地区选择器(当前只是一个简单的点击反应)
  109. regionSelect(e) {
  110. // this.formData.area = e.detail.value[1] + e.detail.value[2]
  111. position.selectAddress(0, 0, res => {
  112. delete res.errMsg
  113. res.area = res.name
  114. delete res.name
  115. this.formData = {
  116. ...this.formData,
  117. ...res
  118. }
  119. })
  120. },
  121. // 提交申请
  122. submitApplication() {
  123. // 表单验证
  124. if (!this.formData.spotImage) {
  125. return uni.showToast({
  126. title: '请上传送餐点照片',
  127. icon: 'error'
  128. })
  129. }
  130. if (!this.formData.spotName) {
  131. return uni.showToast({
  132. title: '请输入送餐点名称',
  133. icon: 'error'
  134. })
  135. }
  136. if (!this.formData.name) {
  137. return uni.showToast({
  138. title: '请输入您的姓名',
  139. icon: 'error'
  140. })
  141. }
  142. if (!this.formData.phone) {
  143. return uni.showToast({
  144. title: '请输入联系手机号',
  145. icon: 'error'
  146. })
  147. }
  148. if (!this.$utils.verificationPhone(this.formData.phone)) {
  149. return uni.showToast({
  150. title: '请输入正确的手机号',
  151. icon: 'none'
  152. })
  153. }
  154. if (!this.formData.area) {
  155. return uni.showToast({
  156. title: '请选择所在地区',
  157. icon: 'error'
  158. })
  159. }
  160. if (!this.formData.address) {
  161. return uni.showToast({
  162. title: '请输入详细地址',
  163. icon: 'error'
  164. })
  165. }
  166. // 显示提交中
  167. uni.showLoading({
  168. title: '提交中...'
  169. })
  170. console.log(this.formData);
  171. // 如果是团员 提交申请
  172. this.$api('addLeader', {
  173. ...this.formData,
  174. }, res => {
  175. uni.hideLoading()
  176. if (res.code == 200) {
  177. uni.showModal({
  178. title: '提交成功!',
  179. content: '我们的工作人员会及时与您联系,\n请保持电话畅通!',
  180. showCancel: false,
  181. confirmColor: '#019245',
  182. success: (res) => {
  183. if (res.confirm) {
  184. // 如果是团员 返回上一页
  185. this.$utils.navigateBack()
  186. }
  187. }
  188. })
  189. }
  190. })
  191. },
  192. // 获取初始值进行赋值 赋值关键部分
  193. assign(data) {
  194. this.formData.address = data.address
  195. this.formData.area = data.area
  196. this.formData.name = data.name
  197. this.formData.phone = data.phone
  198. this.formData.spotImage = data.spotImage
  199. this.formData.spotName = data.spotName
  200. this.formData.id = data.id
  201. },
  202. },
  203. computed: {
  204. buttonText() {
  205. switch (this.status) {
  206. case '-1':
  207. return '提交申请'
  208. case '0':
  209. return '修改申请'
  210. case '1':
  211. return '修改信息'
  212. case '2':
  213. return '重新申请'
  214. default:
  215. return '提交申请'
  216. }
  217. },
  218. toastTitle() {
  219. if (this.status == '2') {
  220. return '审核不通过!'
  221. } else if (this.status == '1') {
  222. return '审核已通过!请前往个人页面右上角切换团长身份'
  223. } else if (this.status == '0') {
  224. return '审核中...'
  225. }
  226. },
  227. toastType() {
  228. if (this.status == '2') {
  229. return 'error'
  230. } else if (this.status == '1') {
  231. return 'success'
  232. } else if (this.status == '0') {
  233. return 'warning'
  234. } else {
  235. return 'info'
  236. }
  237. }
  238. },
  239. onLoad() {
  240. this.$api('queryLeaderInfo', { }, res => {
  241. if (res.code == 200){
  242. this.assign(res.result)
  243. this.status = res.result.status
  244. this.remark = res.result.remark
  245. }
  246. })
  247. }
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .page {
  252. background-color: #f5f5f5;
  253. min-height: 100vh;
  254. }
  255. .banner {
  256. width: 100%;
  257. height: 240rpx;
  258. background-color: #019245;
  259. .banner-image {
  260. width: 100%;
  261. height: 100%;
  262. display: block;
  263. }
  264. }
  265. .content-area {
  266. padding: 20rpx;
  267. }
  268. .section-block {
  269. margin-bottom: 20rpx;
  270. background-color: #fff;
  271. border-radius: 20rpx;
  272. padding: 10rpx 20rpx;
  273. overflow: hidden;
  274. }
  275. .section-title {
  276. font-size: 28rpx;
  277. color: #333;
  278. padding: 20rpx;
  279. // border-bottom: 1rpx solid #f5f5f5;
  280. }
  281. .upload-container {
  282. padding: 20rpx;
  283. min-height: 140rpx;
  284. }
  285. .upload-area {
  286. width: 150rpx;
  287. height: 150rpx;
  288. border: 3rpx dashed $uni-color;
  289. // border-radius: 8rpx;
  290. display: flex;
  291. flex-direction: column;
  292. justify-content: center;
  293. align-items: center;
  294. .plus {
  295. font-size: 80rpx;
  296. color: $uni-color;
  297. line-height: 1;
  298. // margin-bottom: 5rpx;
  299. font-weight: 100;
  300. }
  301. .upload-text {
  302. font-size: 24rpx;
  303. color: $uni-color-third;
  304. }
  305. }
  306. .form-item {
  307. padding: 24rpx 0;
  308. display: flex;
  309. align-items: center;
  310. border-bottom: 2rpx solid #C7C7C7;
  311. &:last-child {
  312. border-bottom: none;
  313. }
  314. }
  315. .label {
  316. flex: 3;
  317. font-size: 28rpx;
  318. color: #333;
  319. padding-left: 10rpx;
  320. }
  321. .input {
  322. flex: 2;
  323. font-size: 28rpx;
  324. // height: 60rpx;
  325. text-align: left;
  326. }
  327. .placeholder,
  328. .region-item text.placeholder {
  329. // height: 60rpx;
  330. color: #999;
  331. }
  332. .region-item {
  333. cursor: pointer;
  334. }
  335. .address-item {
  336. padding: 24rpx 0;
  337. display: flex;
  338. flex-direction: column;
  339. gap: 20rpx;
  340. .address-box {}
  341. .address-input {
  342. padding: 20rpx;
  343. background-color: #F5F5F5;
  344. border-radius: 10rpx;
  345. width: inherit;
  346. height: 60rpx;
  347. font-size: 28rpx;
  348. }
  349. }
  350. .submit-btn {
  351. width: 80%;
  352. margin: 40rpx auto 0;
  353. height: 100rpx;
  354. background-color: $uni-color;
  355. color: #fff;
  356. font-size: 32rpx;
  357. display: flex;
  358. justify-content: center;
  359. align-items: center;
  360. border-radius: 50rpx;
  361. }
  362. .submit-btn-container {
  363. display: flex;
  364. justify-content: space-between;
  365. align-items: center;
  366. margin: 40rpx auto 0;
  367. width: 74%;
  368. .submit-btn-modify {
  369. width: 45%;
  370. height: 90rpx;
  371. background-color: #fff;
  372. color: $uni-color;
  373. font-size: 32rpx;
  374. display: flex;
  375. justify-content: center;
  376. align-items: center;
  377. border-radius: 50rpx;
  378. border: 4rpx solid $uni-color;
  379. }
  380. .submit-btn-save {
  381. width: 45%;
  382. height: 90rpx;
  383. background-color: $uni-color;
  384. color: #fff;
  385. font-size: 32rpx;
  386. display: flex;
  387. justify-content: center;
  388. align-items: center;
  389. border-radius: 50rpx;
  390. }
  391. }
  392. </style>