binding.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <view class="container">
  3. <!-- 图片区域 -->
  4. <img src="../../static/my/shopImg2.png" />
  5. <!-- 表格区域 -->
  6. <view class="form">
  7. <view class="form_title">{{ type === '2' ? '账户解绑' : '账户绑定' }}</view>
  8. <view class="form_name">
  9. 账户
  10. <view class="name_input">
  11. <input type="text" placeholder="请输入商户超级管理员账号" v-model="formName" />
  12. </view>
  13. </view>
  14. <view class="form_password">
  15. 密码
  16. <view class="password_input">
  17. <input type="text" password placeholder="请输入商户超级管理员密码" v-model="formPassword" />
  18. </view>
  19. </view>
  20. <view class="form_msg">{{ info }}</view>
  21. <view class="form_btn" @click="handleClickBtn">{{ type === '2' ? '解绑' : '绑定' }}</view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. // 绑定解绑类型
  30. type: '',
  31. // 身份类型
  32. status: '',
  33. // 绑定失败,请输入正确的账号或者密码
  34. info: '',
  35. // 账户
  36. formName: '',
  37. // 密码
  38. formPassword: '',
  39. code: ''
  40. }
  41. },
  42. onLoad(options) {
  43. this.status = options.status
  44. if (options.type) {
  45. this.type = options.type
  46. uni.setNavigationBarTitle({
  47. title: '验证解绑'
  48. })
  49. }
  50. },
  51. methods: {
  52. handleClickBtn() {
  53. if (!this.formName) {
  54. uni.showToast({
  55. title: '请输入账户名',
  56. icon: 'none',
  57. mask: true
  58. })
  59. return
  60. }
  61. if (!this.formPassword) {
  62. uni.showToast({
  63. title: '请输入密码',
  64. icon: 'none',
  65. mask: true
  66. })
  67. return
  68. }
  69. console.log(this.formName)
  70. console.log(this.formPassword)
  71. uni.login({
  72. provider: 'weixin',
  73. success: (res) => {
  74. this.code = res.code
  75. if (this.type === '2') {
  76. // 解绑
  77. if (this.status === '1') {
  78. // 商户解绑
  79. this.handleUnbind()
  80. } else {
  81. // 业主解绑
  82. this.handleUnbind2()
  83. }
  84. } else {
  85. // 绑定
  86. if (this.status === '1') {
  87. // 商户绑定
  88. this.handleBinding()
  89. } else {
  90. // 业主绑定
  91. this.handleBinding2()
  92. }
  93. }
  94. }
  95. })
  96. },
  97. // 商户绑定请求
  98. async handleBinding() {
  99. const res = await this.$myRequest({
  100. url: '/mhotel/appmanage_code.action',
  101. data: {
  102. code: this.code,
  103. admin_name: this.formName,
  104. password: this.formPassword
  105. }
  106. })
  107. // console.log(res)
  108. if (res.code === 200) {
  109. uni.showToast({
  110. title: res.message,
  111. icon: 'success',
  112. mask: true
  113. })
  114. let data = JSON.stringify(res.data)
  115. setTimeout(() => {
  116. uni.redirectTo({
  117. url: `/pages/shopInfo/shopInfo?type=1&data=${data}`
  118. })
  119. }, 1500)
  120. } else {
  121. uni.showToast({
  122. title: res.message,
  123. icon: 'none',
  124. mask: true
  125. })
  126. }
  127. },
  128. // 业主绑定请求
  129. async handleBinding2() {
  130. const res = await this.$myRequest({
  131. url: '/mhotel/appcode.action',
  132. data: {
  133. code: this.code,
  134. admin_name: this.formName,
  135. password: this.formPassword
  136. }
  137. })
  138. // console.log(res)
  139. if (res.code === 200) {
  140. uni.showToast({
  141. title: res.message,
  142. icon: 'success',
  143. mask: true
  144. })
  145. let data = JSON.stringify(res.data)
  146. setTimeout(() => {
  147. uni.redirectTo({
  148. url: `/pages/shopInfo/shopInfo?type=2&data=${data}`
  149. })
  150. }, 1500)
  151. } else {
  152. uni.showToast({
  153. title: res.message,
  154. icon: 'none',
  155. mask: true
  156. })
  157. }
  158. },
  159. // 商户解绑请求
  160. async handleUnbind() {
  161. const res = await this.$myRequest({
  162. url: '/mhotel/appuncode_ma.action',
  163. data: {
  164. code: this.code,
  165. admin_name: this.formName,
  166. password: this.formPassword
  167. }
  168. })
  169. // console.log(res)
  170. if (res.code === 200) {
  171. uni.showToast({
  172. title: res.message,
  173. icon: 'success',
  174. mask: true
  175. })
  176. setTimeout(() => {
  177. uni.switchTab({
  178. url: '/pages/my/my'
  179. })
  180. }, 1500)
  181. } else {
  182. uni.showToast({
  183. title: res.message,
  184. icon: 'none',
  185. mask: true
  186. })
  187. }
  188. },
  189. // 业主解绑请求
  190. async handleUnbind2() {
  191. const res = await this.$myRequest({
  192. url: '/mhotel/appuncode.action',
  193. data: {
  194. code: this.code,
  195. admin_name: this.formName,
  196. password: this.formPassword
  197. }
  198. })
  199. // console.log(res)
  200. if (res.code === 200) {
  201. uni.showToast({
  202. title: res.message,
  203. icon: 'success',
  204. mask: true
  205. })
  206. setTimeout(() => {
  207. uni.switchTab({
  208. url: '/pages/my/my'
  209. })
  210. }, 1500)
  211. } else {
  212. uni.showToast({
  213. title: res.message,
  214. icon: 'none',
  215. mask: true
  216. })
  217. }
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. .container {
  224. display: flex;
  225. flex-direction: column;
  226. align-items: center;
  227. height: 100vh;
  228. background-color: #fff;
  229. img {
  230. margin-top: 20rpx;
  231. width: 347rpx;
  232. height: 387rpx;
  233. }
  234. .form {
  235. box-sizing: border-box;
  236. padding: 0 30rpx;
  237. margin-top: 35rpx;
  238. width: 690rpx;
  239. height: 548rpx;
  240. border-radius: 23rpx;
  241. box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.25);
  242. .form_title {
  243. line-height: 120rpx;
  244. font-size: 32rpx;
  245. font-weight: bold;
  246. }
  247. .form_name {
  248. display: flex;
  249. align-items: center;
  250. font-size: 28rpx;
  251. .name_input {
  252. display: flex;
  253. align-items: center;
  254. box-sizing: border-box;
  255. padding: 0 24rpx;
  256. margin-left: 25rpx;
  257. width: 545rpx;
  258. height: 80rpx;
  259. border-radius: 15rpx;
  260. border: 1rpx solid #a6a6a6;
  261. input {
  262. width: 100%;
  263. }
  264. }
  265. }
  266. .form_password {
  267. display: flex;
  268. align-items: center;
  269. margin-top: 46rpx;
  270. font-size: 28rpx;
  271. .password_input {
  272. display: flex;
  273. align-items: center;
  274. box-sizing: border-box;
  275. padding: 0 24rpx;
  276. margin-left: 25rpx;
  277. width: 545rpx;
  278. height: 80rpx;
  279. border-radius: 15rpx;
  280. border: 1rpx solid #a6a6a6;
  281. input {
  282. width: 100%;
  283. }
  284. }
  285. }
  286. .form_msg {
  287. margin-top: 23rpx;
  288. height: 32rpx;
  289. color: #d43030;
  290. font-size: 24rpx;
  291. text-align: center;
  292. }
  293. .form_btn {
  294. display: flex;
  295. justify-content: center;
  296. align-items: center;
  297. margin-top: 28rpx;
  298. width: 624rpx;
  299. height: 96rpx;
  300. border-radius: 64rpx;
  301. color: #fff;
  302. font-size: 32rpx;
  303. background-color: #096562;
  304. }
  305. }
  306. }
  307. </style>