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

303 lines
9.0 KiB

  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="解绑团长" leftClick @leftClick="$utils.navigateBack" bgColor="#019245" color="#fff" />
  5. <!-- 当前取餐点 -->
  6. <view class="section" v-if="isBind">
  7. <view class="section-title">当前取餐点</view>
  8. <view class="pickup-item" v-if="currentPickupPoint">
  9. <view class="pickup-image">
  10. <image :src="currentPickupPoint.spotImage" mode="aspectFill"></image>
  11. </view>
  12. <view class="pickup-info">
  13. <view class="pickup-name">{{ currentPickupPoint.spotName }}</view>
  14. <view class="pickup-address">
  15. <view class="pickup-address-icon">
  16. <uv-icon name="map-fill" color="#019245" size="24"></uv-icon>
  17. </view>
  18. <text>{{ currentPickupPoint.area }}{{ currentPickupPoint.address }}</text>
  19. </view>
  20. <view class="pickup-phone">
  21. <uv-icon name="phone-fill" color="#019245" size="24"></uv-icon>
  22. <text>{{ currentPickupPoint.phone }}</text>
  23. </view>
  24. </view>
  25. <view v-if="currentPickupPoint.bindStatus == '0'" class="cancel-btn" disabled>
  26. <text>解绑中...</text>
  27. </view>
  28. <view v-else class="select-btn" @click="deleteLeader">
  29. <text>解绑</text>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 附近取餐点 -->
  34. <view class="section">
  35. <view class="section-title">附近取餐点</view>
  36. <!-- 提示信息 -->
  37. <view class="warning-tip">
  38. <uv-icon name="info-circle" color="#FF5722" size="36"></uv-icon>
  39. <text v-if="isBind">更换取餐地址和团长,需通过平台审核方可更换!</text>
  40. <text v-else>您还未绑定团长请先绑定团长!</text>
  41. </view>
  42. <!-- 取餐点列表 -->
  43. <view class="pickup-list">
  44. <view class="pickup-item" v-for="(item, index) in nearbyPickupPoints" :key="index">
  45. <view class="pickup-image">
  46. <image :src="item.spotImage" mode="aspectFill"></image>
  47. </view>
  48. <view class="pickup-info">
  49. <view class="pickup-name">{{ item.spotName }}</view>
  50. <view class="pickup-address">
  51. <view class="pickup-address-icon">
  52. <uv-icon name="map-fill" color="#019245" size="24"></uv-icon>
  53. </view>
  54. <text>{{ item.area }} {{ item.address }} </text>
  55. </view>
  56. <view class="pickup-phone">
  57. <uv-icon name="phone-fill" color="#019245" size="24"></uv-icon>
  58. <text>{{ item.phone }}</text>
  59. </view>
  60. </view>
  61. <view class="select-btn" @click="updateLeader(item)">
  62. <text>选择</text>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import navbar from '@/components/base/navbar.vue'
  71. // import { currentPickupPoint, nearbyPickupPoints } from '@/static/js/mockTeam.js'
  72. export default {
  73. components: {
  74. navbar
  75. },
  76. data() {
  77. return {
  78. // 当前取餐点
  79. currentPickupPoint:{},
  80. // 附近取餐点列表
  81. nearbyPickupPoints:[],
  82. isBind: true
  83. }
  84. },
  85. methods: {
  86. // 选择取餐点
  87. deleteLeader() {
  88. uni.showModal({
  89. title: '确认解绑',
  90. content: '您确定要解绑团长吗?',
  91. confirmColor: '#019245',
  92. success: (res) => {
  93. if (res.confirm) {
  94. uni.showLoading({
  95. title: '提交中...'
  96. })
  97. this.$api('deleteLeader',{
  98. leaderId: this.currentPickupPoint.id
  99. }, res => {
  100. if (res.code === 200){
  101. uni.hideLoading()
  102. uni.showToast({
  103. title: `${res.message}`
  104. })
  105. this.getLeaderList()
  106. }
  107. })
  108. }
  109. }
  110. })
  111. },
  112. updateLeader(point) {
  113. uni.showModal({
  114. title: '确认选择',
  115. content: '您确定要选择该取餐点吗?需要平台审核通过后才能更换。',
  116. confirmColor: '#019245',
  117. success: (res) => {
  118. if (res.confirm) {
  119. uni.showLoading({
  120. title: '提交中...'
  121. })
  122. this.$api('updateLeader', {
  123. leaderId: point.id
  124. }, res => {
  125. if (res.code == 200) {
  126. uni.hideLoading()
  127. uni.showToast({
  128. title: `${res.message}`,
  129. icon: 'success',
  130. })
  131. this.getLeaderList()
  132. }
  133. })
  134. }
  135. }
  136. })
  137. },
  138. getLeaderList() {
  139. // this.currentPickupPoint = currentPickupPoint
  140. // this.nearbyPickupPoints = []
  141. // this.currentPickupPoint = {}
  142. this.isBind = true
  143. this.$api('queryLeaderList', {}, res => {
  144. if (res.code == 200) {
  145. this.nearbyPickupPoints = res.result.records
  146. }
  147. })
  148. this.$api('queryMyLeader', {}, res => {
  149. if (res.code == 200 && res.result.bindStatus !== '2') {
  150. this.currentPickupPoint = res.result
  151. } else if (res.code == 500 || !res.result || res.result.bindStatus == '2') {
  152. this.isBind = false
  153. }
  154. })
  155. }
  156. },
  157. onLoad() {
  158. this.getLeaderList()
  159. }
  160. }
  161. </script>
  162. <style lang="scss" scoped>
  163. .page {
  164. // background-color: #f5f5f5;
  165. // min-height: 100vh;
  166. }
  167. .section {
  168. width: 96%;
  169. margin: 0 auto;
  170. margin-bottom: 20rpx;
  171. // border-radius: 10rpx;
  172. &-title {
  173. font-size: 32rpx;
  174. font-weight: bold;
  175. color: #333;
  176. padding: 30rpx 30rpx 20rpx;
  177. }
  178. }
  179. .pickup {
  180. &-item {
  181. background-color: #fff;
  182. padding: 20rpx 20rpx;
  183. display: flex;
  184. position: relative;
  185. margin-bottom: 2rpx;
  186. border-radius: 20rpx;
  187. }
  188. &-image {
  189. width: 170rpx;
  190. height: 170rpx;
  191. margin: auto 20rpx auto 0;
  192. overflow: hidden;
  193. image {
  194. width: 100%;
  195. height: 100%;
  196. }
  197. }
  198. &-info {
  199. flex: 1;
  200. display: flex;
  201. flex-direction: column;
  202. justify-content: space-between;
  203. }
  204. &-name {
  205. font-size: 30rpx;
  206. font-weight: bold;
  207. color: #3B3B3B;
  208. margin-bottom: 10rpx;
  209. }
  210. &-address, &-phone {
  211. font-size: 26rpx;
  212. color: $uni-color-third;
  213. display: flex;
  214. align-items: center;
  215. margin-bottom: 8rpx;
  216. width: 85%;
  217. text {
  218. margin-left: 8rpx;
  219. }
  220. &-icon {
  221. height: 100%;
  222. padding-top: 20rpx;
  223. }
  224. }
  225. }
  226. .status-icon {
  227. position: absolute;
  228. right: 30rpx;
  229. top: 50%;
  230. transform: translateY(-50%);
  231. }
  232. // 隔一层会灰雾雾的效果
  233. .cancel-btn {
  234. background-color: $uni-color-second;
  235. color: #fff;
  236. width: 120rpx;
  237. height: 60rpx;
  238. display: flex;
  239. justify-content: center;
  240. align-items: center;
  241. border-radius: 10rpx;
  242. align-self: center;
  243. font-size: 24rpx;
  244. opacity: 0.7;
  245. }
  246. .select-btn {
  247. background-color: $uni-color;
  248. color: #fff;
  249. width: 100rpx;
  250. height: 60rpx;
  251. display: flex;
  252. justify-content: center;
  253. align-items: center;
  254. border-radius: 10rpx;
  255. align-self: center;
  256. font-size: 24rpx;
  257. }
  258. .warning-tip {
  259. background-color: #FFDBDB;
  260. // width: 90%;
  261. margin: 0rpx 40rpx 20rpx 30rpx;
  262. border-radius: 10rpx;
  263. padding: 15rpx 15rpx;
  264. display: flex;
  265. align-items: center;
  266. margin-bottom: 20rpx;
  267. text {
  268. font-size: 26rpx;
  269. color: $uni-color-second;
  270. margin-left: 10rpx;
  271. }
  272. }
  273. .pickup-list {
  274. gap: 20rpx;
  275. .pickup-item {
  276. margin-bottom: 20rpx;
  277. }
  278. }
  279. </style>