敢为人鲜小程序前端代码仓库
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.

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