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

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