address.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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">
  39. <input placeholder-class="input-placeholder" class="input" type="text" :value="form.andName" 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.area}}-{{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. andName: '',
  94. cabinetPositionId: '',
  95. cabinetPositionName: '',
  96. code: '',
  97. },
  98. };
  99. },
  100. mounted() {
  101. // this.initTimes()
  102. },
  103. methods: {
  104. async getArea(keyWord){
  105. const res = await this.$api('signs.getCabinetPosition', {phone: this.form.inputSearch})
  106. if(res.code != 200) {
  107. throw new Error("")
  108. }
  109. return res.data.map(item => {
  110. return { ...item, id: item.cabinetAreaId, name: item.cabinetAreaName }
  111. })
  112. },
  113. async search(){
  114. const res = await this.$api('signs.getCabinetPosition', {phone: this.form.inputSearch})
  115. console.log(res)
  116. },
  117. showArea() {
  118. if(!this.form.inputSearch){
  119. this.$refs.uToast.show({type: 'error', message: '请输入查询内容', position: 'top'})
  120. return
  121. }
  122. this.$refs.area.$open().then(res => {
  123. if(res.arr && res.arr.length > 0){
  124. this.form.cabinetAreaId = res.arr[0].cabinetAreaId
  125. this.form.cabinetAreaName = res.arr[0].cabinetAreaName
  126. }
  127. })
  128. },
  129. async getPos(){
  130. const res = await this.$api('signs.getCabinetPosition', {phone: this.form.inputSearch})
  131. if(res.code != 200) {
  132. throw new Error("")
  133. }
  134. return res.data.map(item => {
  135. return { ...item, id: item.cabinetPositionId, area: item.cabinetAreaName, name: item.cabinetPositionName }
  136. })
  137. },
  138. showPos() {
  139. if(!this.form.inputSearch){
  140. this.$refs.uToast.show({type: 'error', message: '请输入查询内容', position: 'top'})
  141. return
  142. }
  143. this.$refs.pos.$open({}).then(res => {
  144. if(res.arr && res.arr.length > 0){
  145. this.form.cabinetPositionId = res.arr[0].cabinetPositionId
  146. this.form.cabinetPositionName = res.arr[0].cabinetPositionName
  147. this.form.andName = res.arr[0].cabinetAreaName + '-' + res.arr[0].cabinetPositionName
  148. }
  149. })
  150. },
  151. end() {
  152. this.send = false;
  153. },
  154. start() {
  155. this.send = true;
  156. },
  157. codeChange(text) {
  158. this.tips = text;
  159. },
  160. getCode() {
  161. if(!this.form.cabinetPositionId){
  162. this.$refs.uToast.show({type: 'error', message: '请选择阁位', position: 'top'})
  163. return;
  164. }
  165. if(this.$refs.uCode.canGetCode) {
  166. // 模拟向后端请求验证码
  167. this.$refs.uToast.show({
  168. type: 'loading',
  169. message: '正在获取验证码',
  170. })
  171. // TODO 发起请求:
  172. this.$api('signs.sendCode', {cabinetPositionId: this.form.cabinetPositionId}).then(res => {
  173. this.$refs.uToast.hide()
  174. if(res.code == 200){
  175. // 这里此提示会被this.start()方法中的提示覆盖
  176. this.$refs.uToast.show({type: 'success', message: res.msg, position: 'top', duration: 3000})
  177. // 通知验证码组件内部开始倒计时
  178. this.$refs.uCode.start()
  179. }else{
  180. this.$refs.uToast.show({type: 'error', message: res.msg, position: 'top'})
  181. }
  182. })
  183. } else {
  184. uni.$u.toast('倒计时结束后再发送');
  185. }
  186. },
  187. confirm(){
  188. if(!this.form.cabinetPositionId){
  189. this.$refs.uToast.show({type: 'error', message: '请选择阁位', position: 'top'})
  190. return;
  191. }
  192. if(!this.form.code){
  193. this.$refs.uToast.show({type: 'error', message: '请填写经办人验证码', position: 'top'})
  194. return;
  195. }
  196. this.$refs.uToast.show({
  197. type: 'loading',
  198. message: '请稍后',
  199. })
  200. this.$api('signs.openidBinding', {cabinetPositionId: this.form.cabinetPositionId, code: this.form.code}).then(res => {
  201. this.$refs.uToast.hide()
  202. if(res.code == 200){
  203. // 这里此提示会被this.start()方法中的提示覆盖
  204. this.$refs.uToast.show({type: 'success', message: res.msg, position: 'top'})
  205. uni.navigateBack({
  206. delta: 1
  207. })
  208. }else{
  209. this.$refs.uToast.show({type: 'error', message: res.msg, position: 'top'})
  210. }
  211. })
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. @import "./index.scss";
  218. </style>