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

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