index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="app-container">
  3. <u-navbar title="选择游玩人" bgColor="#fff" :fixed="true" :autoBack="false" leftIconColor="#333333" leftIconSize="28"
  4. @leftClick="handleLeftClick">
  5. </u-navbar>
  6. <view class="app-container-item flex-column-center">
  7. <view class="time_period-card ">
  8. <view class="time_period-card_item flex-between" v-for="(item,index) in touristList" :key="index">
  9. <view style="width: calc(100% - 50px);" class="flex-between" @click="onCheckTourist(item,index)">
  10. <view :class="[isChecked(item.id) ? 'checked_box' : 'unchecked_box', 'flex']">
  11. <text v-show="isChecked(item.id)" class="iconfont icon-c_checked"
  12. style="font-size: 10px;color: #fff"></text>
  13. </view>
  14. <view class="card_item">
  15. <text>{{ item.username }}</text>
  16. <text>【身份证】{{ item.idNumber }}</text>
  17. </view>
  18. </view>
  19. <view class="delete_box flex" @click="deleteTourist(item,index)">
  20. <text class="iconfont icon-delete" style="font-size: 20px;color: #BCC4DB"></text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="app-container-btn flex-between">
  26. <view class="btn-item">
  27. <u-button class="btn" :plain="true" color="#2EDAF1" text="新增游玩人" @tap="addTourist()"></u-button>
  28. </view>
  29. <view class="btn-item">
  30. <u-button v-if="touristIdList.length > 0" text="确定" class="btn" type="primary"
  31. @tap="chooseTourist()"></u-button>
  32. <u-button v-else text="确定" class="btn" color="#DDE2EC"></u-button>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. components: {},
  40. data() {
  41. return {
  42. touristList: [{
  43. id: 1,
  44. username: '刘琳琳', // 姓名
  45. idNumber: '430822********0465', // 身份证号
  46. IDType: '',
  47. checked: false,
  48. }, {
  49. id: 2,
  50. username: '刘琳X', // 姓名
  51. idNumber: '430822********0464', // 身份证号
  52. IDType: '',
  53. checked: false,
  54. }, {
  55. id: 3,
  56. username: '刘琳Y', // 姓名
  57. idNumber: '430822********0463', // 身份证号
  58. IDType: '',
  59. checked: false,
  60. }],
  61. touristIdList: [],
  62. };
  63. },
  64. computed: {
  65. isSubmitEnabled() {
  66. return true;
  67. },
  68. },
  69. onLoad(options) {
  70. // this.touristIdList = JSON.parse(options.touristIdList);
  71. console.log('onLoad', this.touristIdList)
  72. },
  73. onShow() {},
  74. methods: {
  75. isChecked(id) {
  76. return this.touristIdList.findIndex(v => v == id) > -1
  77. },
  78. /**
  79. * 删除游玩人
  80. * @param item
  81. * @param index
  82. */
  83. deleteTourist(item, index) {
  84. uni.showModal({
  85. title: '提示',
  86. content: `确定删除${item.username}吗?`,
  87. success: res => {
  88. if (res.confirm) {
  89. let cIndex = this.touristIdList.findIndex(v => v == item.id);
  90. let tIndex = this.touristList.findIndex(v => v.id == item.id);
  91. console.log(cIndex)
  92. if (cIndex > -1) {
  93. this.touristIdList.splice(cIndex, 1);
  94. }
  95. if (tIndex > -1) {
  96. this.touristList.splice(tIndex, 1);
  97. }
  98. uni.showToast({
  99. title: '操作成功',
  100. icon: 'none',
  101. duration: 1000,
  102. mask: true,
  103. success: () => {}
  104. })
  105. }
  106. }
  107. });
  108. },
  109. /**
  110. * 切换选择游玩人
  111. * @param item
  112. * @param index
  113. */
  114. onCheckTourist(item, index) {
  115. let cIndex = this.touristIdList.findIndex(v => v == item.id);
  116. console.log(cIndex)
  117. if (cIndex > -1) {
  118. this.touristIdList.splice(cIndex, 1);
  119. } else {
  120. this.touristIdList.push(item.id)
  121. }
  122. },
  123. /**
  124. * 添加游玩人
  125. */
  126. addTourist() {
  127. console.log('添加游玩人')
  128. uni.navigateTo({
  129. url: '/pages/tourist/add'
  130. });
  131. },
  132. /**
  133. * 选择游玩人
  134. */
  135. chooseTourist() {
  136. },
  137. handleLeftClick() {
  138. //获取页面栈的长度
  139. const canNavBack = getCurrentPages()
  140. //判断是否刷新了浏览器,刷新了浏览器,页面栈只有当前一个
  141. if (canNavBack && canNavBack.length > 1) {
  142. uni.navigateBack({
  143. delta: 1
  144. })
  145. } else {
  146. history.back()
  147. }
  148. },
  149. }
  150. };
  151. </script>
  152. <style lang="scss" scoped>
  153. .app-container {
  154. width: 100vw;
  155. //background: #fff;
  156. position: relative;
  157. height: 100vh;
  158. &-item {
  159. position: absolute;
  160. top: 44px;
  161. padding: 10px 20px 100px 20px;
  162. width: calc(100%);
  163. box-sizing: border-box;
  164. .time_period-card {
  165. width: calc(100%);
  166. margin-top: 10px;
  167. position: relative;
  168. display: flex;
  169. flex-direction: column;
  170. &_item {
  171. border-radius: 8px;
  172. box-sizing: border-box;
  173. padding: 0 10px;
  174. background: #fff;
  175. &:not(:last-child) {
  176. margin-bottom: 10px;
  177. }
  178. }
  179. .checked_box {
  180. width: 18px;
  181. height: 18px;
  182. background: #2EDAF1;
  183. border-radius: 50%;
  184. box-sizing: border-box;
  185. }
  186. .unchecked_box {
  187. width: 18px;
  188. height: 18px;
  189. border: 1px solid #DADEEC;
  190. background: #F8FAFD;
  191. border-radius: 50%;
  192. box-sizing: border-box;
  193. }
  194. .delete_box {
  195. width: 50px;
  196. height: 70px;
  197. //background: #2EDAF1;
  198. }
  199. .card_item {
  200. //width: calc(100% - 18px - 50px);
  201. flex: 1;
  202. display: flex;
  203. flex-direction: column;
  204. padding: 10px 20px;
  205. font-size: 14px;
  206. color: #333333;
  207. border-radius: 8px;
  208. box-sizing: border-box;
  209. text {
  210. height: 26px;
  211. line-height: 26px;
  212. }
  213. }
  214. }
  215. .top-card {
  216. width: calc(100%);
  217. box-sizing: border-box;
  218. margin-top: 10px;
  219. background: #fff;
  220. border-radius: 8px;
  221. position: relative;
  222. display: flex;
  223. flex-direction: column;
  224. padding: 20px 10px;
  225. box-sizing: border-box;
  226. .title {
  227. width: 100%;
  228. font-size: 20px;
  229. color: #1D2633;
  230. }
  231. .time {
  232. color: #1D2633;
  233. font-size: 15px;
  234. }
  235. }
  236. }
  237. &-btn {
  238. position: fixed;
  239. bottom: 0;
  240. height: 80px;
  241. text-align: center;
  242. background: white;
  243. width: 100%;
  244. padding: 0 24px;
  245. box-sizing: border-box;
  246. .btn-item {
  247. width: calc(50% - 10px);
  248. .btn {
  249. width: 100%;
  250. border-top-right-radius: 25px !important;
  251. border-top-left-radius: 25px !important;
  252. border-bottom-left-radius: 25px !important;
  253. border-bottom-right-radius: 25px !important;
  254. }
  255. }
  256. }
  257. }
  258. </style>