address.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <view class="sign-page">
  3. <view class="view-wrap">
  4. <view class="card">
  5. <!-- <view class="form-item">
  6. <view class="form-item__title">
  7. <view class="name">区域</view>
  8. <view class="extra"></view>
  9. </view>
  10. <view class="form-item__input__wrap">
  11. <view class="form-item__input" @click="showArea">
  12. <input placeholder-class="input-placeholder" class="input" type="text" :value="form.AreaName" placeholder="请选择区域" disabled />
  13. <view class="icon"><image style="width: 16rpx;height: 16rpx;" src="/static/app/page3/arrow-down.png" mode="aspectFit"></image></view>
  14. </view>
  15. </view>
  16. </view> -->
  17. <view class="form-item">
  18. <view class="form-item__title">
  19. <view class="name">经办人姓名/电话/逝者姓名</view>
  20. <view class="extra"></view>
  21. </view>
  22. <view class="form-item__input__wrap">
  23. <view class="form-item__input">
  24. <input placeholder-class="input-placeholder" class="input" type="text" v-model="form.inputSearch" placeholder="经办人姓名或电话或逝者姓名" />
  25. <view class="inlne-button-wrap">
  26. <button class="u-reset-button button" type="default" @click="showPos">查询</button>
  27. </view>
  28. <!-- <view class="icon"><image style="width: 16rpx;height: 16rpx;" src="/static/app/page3/arrow-down.png" mode="aspectFit"></image></view> -->
  29. </view>
  30. </view>
  31. </view>
  32. <view class="form-item">
  33. <view class="form-item__title">
  34. <view class="name">阁位</view>
  35. <view class="extra"></view>
  36. </view>
  37. <view class="form-item__input__wrap">
  38. <view class="form-item__input" @click="showPos">
  39. <input placeholder-class="input-placeholder" class="input" type="text" :value="form.cabinetPositionName" placeholder="请选择阁位" disabled />
  40. <view class="icon"><image style="width: 16rpx;height: 16rpx;" src="/static/app/page3/arrow-down.png" mode="aspectFit"></image></view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="form-item">
  45. <view class="form-item__title">
  46. <view class="name">经办人验证码</view>
  47. <view class="extra">
  48. </view>
  49. </view>
  50. <view class="form-item__input__wrap">
  51. <view class="form-item__input">
  52. <input placeholder-class="input-placeholder" class="input" type="text" v-model="form.code" placeholder="请输入验证码" />
  53. </view>
  54. </view>
  55. </view>
  56. <view class="tip-btn" :class="{disable: send}" @click="getCode">{{tips}}</view>
  57. </view>
  58. <view class="button-wrap">
  59. <button type="default" class="u-reset-button sing-btn" @click="confirm">
  60. 确认绑定
  61. </button>
  62. </view>
  63. </view>
  64. <!-- 区域 -->
  65. <c-form-type-action-sheet ref="area" title="请选择区域" :loadData="getArea">
  66. <template v-slot="{item}">
  67. <view>{{item.name}}</view>
  68. </template>
  69. </c-form-type-action-sheet>
  70. <!-- 阁位 -->
  71. <c-form-type-action-sheet ref="pos" title="请选择阁位" :loadData="getPos">
  72. <template v-slot="{item}">
  73. <view>{{item.name}}</view>
  74. </template>
  75. </c-form-type-action-sheet>
  76. <!-- 验证码 -->
  77. <u-code :seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange"></u-code>
  78. <!-- 提示框 -->
  79. <u-toast ref="uToast"></u-toast>
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. tips: '获取验证码',
  87. seconds: 60,
  88. send: false,
  89. form: {
  90. inputSearch: '',
  91. cabinetAreaId: '',
  92. cabinetAreaName: '',
  93. cabinetPositionId: '',
  94. cabinetPositionName: '',
  95. code: '',
  96. },
  97. };
  98. },
  99. mounted() {
  100. // this.initTimes()
  101. },
  102. methods: {
  103. async getArea(keyWord){
  104. const res = await this.$api('signs.getCabinetPosition', {phone: this.form.inputSearch})
  105. if(res.code != 200) {
  106. throw new Error("")
  107. }
  108. return res.data.map(item => {
  109. return { ...item, id: item.cabinetAreaId, name: item.cabinetAreaName }
  110. })
  111. },
  112. async search(){
  113. const res = await this.$api('signs.getCabinetPosition', {phone: this.form.inputSearch})
  114. console.log(res)
  115. },
  116. showArea() {
  117. if(!this.form.inputSearch){
  118. this.$refs.uToast.show({type: 'error', message: '请输入查询内容', position: 'top'})
  119. return
  120. }
  121. this.$refs.area.$open().then(res => {
  122. if(res.arr && res.arr.length > 0){
  123. this.form.cabinetAreaId = res.arr[0].cabinetAreaId
  124. this.form.cabinetAreaName = res.arr[0].cabinetAreaName
  125. }
  126. })
  127. },
  128. async getPos(){
  129. const res = await this.$api('signs.getCabinetPosition', {phone: this.form.inputSearch})
  130. if(res.code != 200) {
  131. throw new Error("")
  132. }
  133. return res.data.map(item => {
  134. return { ...item, id: item.cabinetPositionId, name: item.cabinetPositionName }
  135. })
  136. },
  137. showPos() {
  138. if(!this.form.inputSearch){
  139. this.$refs.uToast.show({type: 'error', message: '请输入查询内容', position: 'top'})
  140. return
  141. }
  142. this.$refs.pos.$open({}).then(res => {
  143. if(res.arr && res.arr.length > 0){
  144. this.form.cabinetPositionId = res.arr[0].cabinetPositionId
  145. this.form.cabinetPositionName = res.arr[0].cabinetPositionName
  146. }
  147. })
  148. },
  149. end() {
  150. this.send = false;
  151. },
  152. start() {
  153. this.send = true;
  154. },
  155. codeChange(text) {
  156. this.tips = text;
  157. },
  158. getCode() {
  159. if(!this.form.cabinetPositionId){
  160. this.$refs.uToast.show({type: 'error', message: '请选择阁位', position: 'top'})
  161. return;
  162. }
  163. if(this.$refs.uCode.canGetCode) {
  164. // 模拟向后端请求验证码
  165. this.$refs.uToast.show({
  166. type: 'loading',
  167. message: '正在获取验证码',
  168. })
  169. // TODO 发起请求:
  170. this.$api('signs.sendCode', {cabinetPositionId: this.form.cabinetPositionId}).then(res => {
  171. this.$refs.uToast.hide()
  172. if(res.code == 200){
  173. // 这里此提示会被this.start()方法中的提示覆盖
  174. this.$refs.uToast.show({type: 'success', message: '验证码已发送', position: 'top'})
  175. // 通知验证码组件内部开始倒计时
  176. this.$refs.uCode.start()
  177. }else{
  178. this.$refs.uToast.show({type: 'error', message: res.msg, position: 'top'})
  179. }
  180. })
  181. } else {
  182. uni.$u.toast('倒计时结束后再发送');
  183. }
  184. },
  185. confirm(){
  186. if(!this.form.cabinetPositionId){
  187. this.$refs.uToast.show({type: 'error', message: '请选择阁位', position: 'top'})
  188. return;
  189. }
  190. if(!this.form.code){
  191. this.$refs.uToast.show({type: 'error', message: '请填写经办人验证码', position: 'top'})
  192. return;
  193. }
  194. this.$refs.uToast.show({
  195. type: 'loading',
  196. message: '请稍后',
  197. })
  198. this.$api('signs.openidBinding', {cabinetPositionId: this.form.cabinetPositionId, code: this.form.code}).then(res => {
  199. this.$refs.uToast.hide()
  200. if(res.code == 200){
  201. // 这里此提示会被this.start()方法中的提示覆盖
  202. this.$refs.uToast.show({type: 'success', message: res.msg, position: 'top'})
  203. uni.navigateBack({
  204. delta: 1
  205. })
  206. }else{
  207. this.$refs.uToast.show({type: 'error', message: res.msg, position: 'top'})
  208. }
  209. })
  210. }
  211. }
  212. }
  213. </script>
  214. <style lang="scss" scoped>
  215. @import "./index.scss";
  216. </style>