editEmergencyContact.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="container">
  3. <uni-nav-bar fixed :border="false" backgroundColor="#fff" title="创建联系人" :statusBar="true"
  4. left-icon="left" @clickLeft="$navBack()" @clickRight="clickRight">
  5. <!-- #ifndef MP-WEIXIN -->
  6. <template v-slot:right>
  7. <view>保存</view>
  8. </template>
  9. <!-- #endif -->
  10. </uni-nav-bar>
  11. <view class="container-body">
  12. <uni-forms ref="form" err-show-type="toast" :model="formData">
  13. <view class="box" v-for="(item,index) in list" :key="index">
  14. <view class="box-title">联系人{{index+1}}</view>
  15. <uni-forms-item label="">
  16. <uni-easyinput
  17. v-model="list[index].name"
  18. type="text"
  19. :inputBorder="false"
  20. placeholder="联系人姓名"
  21. :primaryColor="'#c0c4cc'"
  22. :placeholderStyle="placeholderStyle"
  23. :styles="inpuStyle"
  24. maxlength="16"
  25. />
  26. </uni-forms-item>
  27. <uni-forms-item label="">
  28. <uni-easyinput
  29. v-model="list[index].number"
  30. type="number"
  31. :inputBorder="false"
  32. placeholder="电话号码"
  33. :primaryColor="'#c0c4cc'"
  34. :placeholderStyle="placeholderStyle"
  35. :styles="inpuStyle"
  36. maxlength="16"
  37. />
  38. </uni-forms-item>
  39. </view>
  40. </uni-forms>
  41. <!-- 最多设置8个号码 -->
  42. <view class="tips">剩余{{num - this.list.length}}个联系人可新增</view>
  43. </view>
  44. <view class="footer-btn">
  45. <view class="addbtn" @click="handleAdd">新增</view>
  46. <!-- #ifdef MP-WEIXIN -->
  47. <view class="addbtn savebtn" @click="clickRight">保存</view>
  48. <!-- #endif -->
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. rightText: '设置',
  57. // 最多设置8个号码
  58. num: 8,
  59. list: [{
  60. name: "",
  61. number: "",
  62. sos: false
  63. }],
  64. formData: {},
  65. placeholderStyle: "{font-family: PingFang SC, PingFang SC;font-weight: 400;font-size: 30rpx;color: #CCCCCC;}",
  66. inpuStyle: {
  67. fontFamily: "PingFang SC, PingFang SC",
  68. fontWeight: 400,
  69. fontSize: "30rpx",
  70. color: "#333",
  71. }
  72. }
  73. },
  74. onLoad(option) {
  75. this.num = option.count || 8
  76. },
  77. methods: {
  78. handleAdd() {
  79. if(this.list.length > this.num - 1) {
  80. uni.showModal({
  81. content: "最多可以添加8个联系人,请在“常用联系人”中,左滑删除联系人"
  82. })
  83. return
  84. }
  85. this.list.push({
  86. name: "",
  87. number: "",
  88. sos: false
  89. })
  90. },
  91. clickRight() {
  92. const badList = this.list.filter(item=>!item.name || !item.number)
  93. if(badList&&badList.length > 0) {
  94. const badListText = badList.map((it,index)=> '联系人' + (this.list.indexOf(it) + 1))
  95. uni.showModal({
  96. content: badListText.join(',') + "信息不完整,不完整的不会保存,是否继续?",
  97. success: (res)=> {
  98. if (res.confirm) {
  99. const saveList = this.list.filter(item=>item.name && item.number)
  100. uni.$emit("getSaveList",saveList)
  101. uni.navigateBack()
  102. } else if (res.cancel) {
  103. console.log('用户点击取消');
  104. }
  105. }
  106. })
  107. } else {
  108. const saveList = this.list.filter(item=>item.name && item.number)
  109. uni.$emit("getSaveList",saveList)
  110. uni.navigateBack()
  111. }
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. ::v-deep {
  118. .uni-forms-item {
  119. margin-bottom: 20rpx;
  120. }
  121. .uni-forms-item__content{
  122. background-color: #fff;
  123. border-radius: 6rpx;
  124. overflow: hidden;
  125. }
  126. }
  127. .container-body {
  128. padding: 24rpx;
  129. font-family: PingFang SC, PingFang SC;
  130. font-weight: 400;
  131. font-size: 30rpx;
  132. color: #333333;
  133. .box-title {
  134. margin-bottom: 24rpx;
  135. }
  136. .tips{
  137. font-size: 24rpx;
  138. color: #999;
  139. margin-bottom: 50rpx;
  140. }
  141. }
  142. .footer-btn {
  143. display: flex;
  144. align-items: center;
  145. justify-content: center;
  146. font-family: PingFang SC, PingFang SC;
  147. font-weight: 400;
  148. font-size: 32rpx;
  149. }
  150. .addbtn {
  151. width: 200rpx;
  152. height: 88rpx;
  153. margin-right: 50rpx;
  154. line-height: 88rpx;
  155. border-radius: 44rpx 44rpx 44rpx 44rpx;
  156. text-align: center;
  157. background-color: #fff;
  158. color: #FF7700;
  159. border: 1rpx solid #FF7700;
  160. }
  161. .savebtn {
  162. margin-right: 0 !important;
  163. background-color: #FF7700 !important;
  164. color: #FFFFFF !important;
  165. }
  166. </style>