peopleList.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="addpeople">
  3. <view class="list">
  4. <!-- <u-checkbox-group v-model="checkboxValue1" placement="column" @change="checkboxChange" shape="circle" size=32> -->
  5. <view class="list-item" v-for="(item, index) in checkboxList" :key="index">
  6. <!-- <u-checkbox v-if="peopelList" iconSize=32 style="padding: 0 100rpx;" :name="item" activeColor="#1E9F6A"></u-checkbox> -->
  7. <radio v-if="peopelList" color="#1E9F6A" style="font-size: 26rpx;" :checked="item.checked"
  8. :value="index" @click="checkbox(index)"></radio>
  9. <view class="" style="margin:0 64rpx 0 32rpx;width: 70rpx;">
  10. {{item.name}}
  11. </view>
  12. <view class="">
  13. {{item.phone}}
  14. </view>
  15. <view class="image" style="flex: 1;text-align: right;align-items: center;">
  16. <text class=""
  17. style="font-size: 28rpx;color: #1E9F6A;border-right: 1rpx solid #1E9F6A;padding-right: 30rpx;margin-right: 30rpx;"
  18. @click="dele(item.id)">
  19. 删除
  20. </text>
  21. <image src="../../static/editIcon.png" mode="widthFix" @click="edit(item)"></image>
  22. <!-- <image src="../../static/editIcon.png" mode="widthFix"></image> -->
  23. </view>
  24. </view>
  25. <!-- </u-checkbox-group> -->
  26. </view>
  27. <view class="navbar">
  28. <view class="navbar-item" @click="addpeople">
  29. + 新增出行人
  30. </view>
  31. <view class="navbar-item sure" v-if="peopelList" @click="surePeople">
  32. 确定出行人
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. // import peopelInfo from "../components/peopleInfo.vue"
  39. export default {
  40. data() {
  41. return {
  42. // 选择列表
  43. peopelList: false,
  44. //出行人表单显示隐藏
  45. peopelInfoShow: 1,
  46. // 出行人选择
  47. checkboxValue1: [],
  48. // 出行人列表
  49. checkboxList: [
  50. // {name: '吴某某',disabled: false,number:"1568945752"},
  51. // {name: '吴某某',disabled: false,number:"1568945752"},
  52. ],
  53. }
  54. },
  55. components: {
  56. // peopelInfo
  57. },
  58. onLoad(options) {
  59. // console.log(options)
  60. if (options.id == 0) {
  61. this.peopelList = false
  62. } else {
  63. this.peopelList = true
  64. }
  65. this.init()
  66. },
  67. onShow() {
  68. let token = uni.getStorageSync("token")
  69. if (!token) {
  70. //未登录
  71. uni.showToast({
  72. title: "请先登录",
  73. icon: 'none'
  74. })
  75. setTimeout(() => {
  76. uni.navigateBack({
  77. delta: 1
  78. })
  79. }, 1500)
  80. return false
  81. }
  82. this.init()
  83. },
  84. methods: {
  85. init() {
  86. uni.$u.http.post('/api/traveler/list', {
  87. custom: {
  88. auth: true
  89. }
  90. }).then((res) => {
  91. // console.log(res)
  92. this.checkboxList = res
  93. // this.$store.commit("getlist",res)
  94. let nawarr = this.checkboxList
  95. nawarr.forEach(item => {
  96. item.checked = false
  97. })
  98. this.checkboxList = nawarr
  99. // console.log(this.checkboxList)
  100. }).catch((err) => {
  101. console.log(err)
  102. })
  103. },
  104. // // 选择
  105. // checkboxChange(e) {
  106. // console.log('change', e);
  107. // },
  108. // 选择
  109. checkbox(index) {
  110. let data = this.checkboxList
  111. if (data[index].checked) {
  112. data[index].checked = false;
  113. } else {
  114. data[index].checked = true;
  115. }
  116. this.checkboxList = JSON.parse(JSON.stringify(data))
  117. let newarr = this.checkboxList
  118. let arr = []
  119. newarr.forEach(item => {
  120. if (item.checked) {
  121. arr.push(item)
  122. }
  123. })
  124. this.$store.commit('getpeopleList', arr)
  125. },
  126. // 确定添加联系人
  127. surePeople() {
  128. uni.navigateBack({
  129. delta: 1
  130. });
  131. },
  132. // 查看出行人
  133. edit(item) {
  134. let info = JSON.stringify(item)
  135. uni.navigateTo({
  136. url: `/pages/peopleList/addPeople?info=${info}&state=0`
  137. })
  138. },
  139. // 删除出行人
  140. dele(id) {
  141. uni.showModal({
  142. title: "提示",
  143. content: "确认删除吗?",
  144. success: (res) => {
  145. if (res.confirm) {
  146. this.$showLoadding("删除中")
  147. uni.$u.http.post('/api/traveler/delete', {
  148. id
  149. }, {
  150. custom: {
  151. auth: true
  152. }
  153. }).then((res) => {
  154. uni.hideLoading()
  155. this.$toast("删除成功")
  156. this.init()
  157. }).catch((err) => {
  158. console.log(err)
  159. })
  160. } else if (res.cancel) {
  161. console.log('用户点击取消');
  162. }
  163. }
  164. })
  165. },
  166. // 添加出行人
  167. addpeople() {
  168. uni.navigateTo({
  169. url: "/pages/peopleList/addPeople?state=1"
  170. })
  171. }
  172. }
  173. }
  174. </script>
  175. <style lang="less">
  176. .u-cell__body--large.data-v-913eaa32 {
  177. padding: 48rpx 0 !important;
  178. box-sizing: border-box;
  179. }
  180. page {
  181. font-size: 32rpx;
  182. }
  183. .list {
  184. // margin: 50rpx 30rpx;
  185. .list-item {
  186. display: flex;
  187. justify-content: space-between;
  188. align-items: center;
  189. image {
  190. width: 36rpx;
  191. margin-bottom: 0;
  192. }
  193. border-bottom: 1rpx solid #E3E3E3;
  194. padding: 30rpx;
  195. }
  196. }
  197. .navbar {
  198. width: 100%;
  199. height: 104rpx;
  200. line-height: 104rpx;
  201. display: flex;
  202. border-top: 1rpx solid #E3E3E3;
  203. position: fixed;
  204. left: 0;
  205. bottom: 0;
  206. .navbar-item {
  207. // width: 50%;
  208. flex: 1;
  209. text-align: center;
  210. }
  211. .sure {
  212. background: #1E9F6A;
  213. border-radius: 0px 16rpx 0px 0px;
  214. color: #FFFFFF;
  215. }
  216. }
  217. </style>