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

388 lines
11 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 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.locationImage">
  16. <view class="plus">+</view>
  17. <view class="upload-text">添加图片</view>
  18. </view>
  19. <image v-else :src="formData.locationImage" 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.name" 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.contactName" 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.contactPhone" 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.region || '请选择' }}</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. locationImage: '', // 上传的送餐点照片
  79. name: '', // 送餐点名称
  80. contactName: '', // 联系人姓名
  81. contactPhone: '', // 联系电话
  82. region: '', // 所在地区
  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.locationImage = res.tempFilePaths[0]
  100. }
  101. })
  102. },
  103. // 显示地区选择器(当前只是一个简单的点击反应)
  104. regionSelect(e) {
  105. this.formData.region = e.detail.value[1] + e.detail.value[2]
  106. },
  107. // 提交申请
  108. submitApplication() {
  109. // 表单验证
  110. if (!this.formData.locationImage) {
  111. return uni.showToast({
  112. title: '请上传送餐点照片',
  113. icon: 'none'
  114. })
  115. }
  116. if (!this.formData.name) {
  117. return uni.showToast({
  118. title: '请输入送餐点名称',
  119. icon: 'none'
  120. })
  121. }
  122. if (!this.formData.contactName) {
  123. return uni.showToast({
  124. title: '请输入您的姓名',
  125. icon: 'none'
  126. })
  127. }
  128. if (!this.formData.contactPhone) {
  129. return uni.showToast({
  130. title: '请输入联系手机号',
  131. icon: 'none'
  132. })
  133. }
  134. if (!this.$utils.verificationPhone(this.formData.contactPhone)) {
  135. return uni.showToast({
  136. title: '请输入正确的手机号',
  137. icon: 'none'
  138. })
  139. }
  140. if (!this.formData.region) {
  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. setTimeout(() => {
  158. uni.hideLoading()
  159. if (this.identity) {
  160. // 如果是团长 保存表单信息 直接返回了
  161. this.saveInfo()
  162. return
  163. }
  164. uni.showModal({
  165. title: '提交成功!',
  166. content: '我们的工作人员会及时与您联系,\n请保持电话畅通!',
  167. showCancel: false,
  168. confirmColor: '#019245',
  169. success: (res) => {
  170. if (res.confirm) {
  171. // 如果是团员 延迟返回上一页
  172. setTimeout(() => {
  173. this.$utils.navigateBack()
  174. }, 500)
  175. }
  176. }
  177. })
  178. }, 1000)
  179. },
  180. // 保存信息 针对团长端
  181. saveInfo() {
  182. uni.setStorageSync('team_form_data', JSON.stringify(this.formData))
  183. uni.showToast({
  184. title: '保存成功!',
  185. icon: 'none',
  186. duration: 2000
  187. })
  188. }
  189. },
  190. onLoad() {
  191. if (this.identity) {
  192. // 如果是团员 才去获取团长信息
  193. const addData = uni.getStorageSync('team_form_data')
  194. if (addData) {
  195. this.beModify = true
  196. this.formData = JSON.parse(addData)
  197. }
  198. }
  199. }
  200. }
  201. </script>
  202. <style lang="scss" scoped>
  203. .page {
  204. background-color: #f5f5f5;
  205. min-height: 100vh;
  206. }
  207. .banner {
  208. width: 100%;
  209. height: 240rpx;
  210. background-color: #019245;
  211. .banner-image {
  212. width: 100%;
  213. height: 100%;
  214. display: block;
  215. }
  216. }
  217. .content-area {
  218. padding: 20rpx;
  219. }
  220. .section-block {
  221. margin-bottom: 20rpx;
  222. background-color: #fff;
  223. border-radius: 20rpx;
  224. padding: 10rpx 20rpx;
  225. overflow: hidden;
  226. }
  227. .section-title {
  228. font-size: 28rpx;
  229. color: #333;
  230. padding: 20rpx;
  231. // border-bottom: 1rpx solid #f5f5f5;
  232. }
  233. .upload-container {
  234. padding: 20rpx;
  235. min-height: 140rpx;
  236. }
  237. .upload-area {
  238. width: 150rpx;
  239. height: 150rpx;
  240. border: 3rpx dashed $uni-color;
  241. // border-radius: 8rpx;
  242. display: flex;
  243. flex-direction: column;
  244. justify-content: center;
  245. align-items: center;
  246. .plus {
  247. font-size: 80rpx;
  248. color: $uni-color;
  249. line-height: 1;
  250. // margin-bottom: 5rpx;
  251. font-weight: 100;
  252. }
  253. .upload-text {
  254. font-size: 24rpx;
  255. color: $uni-color-third;
  256. }
  257. }
  258. .form-item {
  259. padding: 24rpx 0;
  260. display: flex;
  261. align-items: center;
  262. border-bottom: 2rpx solid #C7C7C7;
  263. &:last-child {
  264. border-bottom: none;
  265. }
  266. }
  267. .label {
  268. flex: 3;
  269. font-size: 28rpx;
  270. color: #333;
  271. padding-left: 10rpx;
  272. }
  273. .input {
  274. flex: 2;
  275. font-size: 28rpx;
  276. // height: 60rpx;
  277. text-align: left;
  278. }
  279. .placeholder,
  280. .region-item text.placeholder {
  281. // height: 60rpx;
  282. color: #999;
  283. }
  284. .region-item {
  285. cursor: pointer;
  286. }
  287. .address-item {
  288. padding: 24rpx 0;
  289. display: flex;
  290. flex-direction: column;
  291. gap: 20rpx;
  292. .address-box {}
  293. .address-input {
  294. padding: 20rpx;
  295. background-color: #F5F5F5;
  296. border-radius: 10rpx;
  297. width: inherit;
  298. height: 60rpx;
  299. font-size: 28rpx;
  300. }
  301. }
  302. .submit-btn {
  303. width: 80%;
  304. margin: 40rpx auto 0;
  305. height: 100rpx;
  306. background-color: $uni-color;
  307. color: #fff;
  308. font-size: 32rpx;
  309. display: flex;
  310. justify-content: center;
  311. align-items: center;
  312. border-radius: 50rpx;
  313. }
  314. .submit-btn-container {
  315. display: flex;
  316. justify-content: space-between;
  317. align-items: center;
  318. margin: 40rpx auto 0;
  319. width: 74%;
  320. .submit-btn-modify {
  321. width: 45%;
  322. height: 90rpx;
  323. background-color: #fff;
  324. color: $uni-color;
  325. font-size: 32rpx;
  326. display: flex;
  327. justify-content: center;
  328. align-items: center;
  329. border-radius: 50rpx;
  330. border: 4rpx solid $uni-color;
  331. }
  332. .submit-btn-save {
  333. width: 45%;
  334. height: 90rpx;
  335. background-color: $uni-color;
  336. color: #fff;
  337. font-size: 32rpx;
  338. display: flex;
  339. justify-content: center;
  340. align-items: center;
  341. border-radius: 50rpx;
  342. }
  343. }
  344. </style>