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

401 lines
12 KiB

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