| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <template>
- <view class="container">
- <!-- 图片区域 -->
- <img src="../../static/my/shopImg2.png" />
- <!-- 表格区域 -->
- <view class="form">
- <view class="form_title">{{ type === '2' ? '账户解绑' : '账户绑定' }}</view>
- <view class="form_name">
- 账户
- <view class="name_input">
- <input type="text" placeholder="请输入商户超级管理员账号" v-model="formName" />
- </view>
- </view>
- <view class="form_password">
- 密码
- <view class="password_input">
- <input type="text" password placeholder="请输入商户超级管理员密码" v-model="formPassword" />
- </view>
- </view>
- <view class="form_msg">{{ info }}</view>
- <view class="form_btn" @click="handleClickBtn">{{ type === '2' ? '解绑' : '绑定' }}</view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 绑定解绑类型
- type: '',
- // 身份类型
- status: '',
- // 绑定失败,请输入正确的账号或者密码
- info: '',
- // 账户
- formName: '',
- // 密码
- formPassword: '',
- code: ''
- }
- },
- onLoad(options) {
- this.status = options.status
- if (options.type) {
- this.type = options.type
- uni.setNavigationBarTitle({
- title: '验证解绑'
- })
- }
- },
- methods: {
- handleClickBtn() {
- if (!this.formName) {
- uni.showToast({
- title: '请输入账户名',
- icon: 'none',
- mask: true
- })
- return
- }
- if (!this.formPassword) {
- uni.showToast({
- title: '请输入密码',
- icon: 'none',
- mask: true
- })
- return
- }
- console.log(this.formName)
- console.log(this.formPassword)
- uni.login({
- provider: 'weixin',
- success: (res) => {
- this.code = res.code
- if (this.type === '2') {
- // 解绑
- if (this.status === '1') {
- // 商户解绑
- this.handleUnbind()
- } else {
- // 业主解绑
- this.handleUnbind2()
- }
- } else {
- // 绑定
- if (this.status === '1') {
- // 商户绑定
- this.handleBinding()
- } else {
- // 业主绑定
- this.handleBinding2()
- }
- }
- }
- })
- },
- // 商户绑定请求
- async handleBinding() {
- const res = await this.$myRequest({
- url: '/mhotel/appmanage_code.action',
- data: {
- code: this.code,
- admin_name: this.formName,
- password: this.formPassword
- }
- })
- // console.log(res)
- if (res.code === 200) {
- uni.showToast({
- title: res.message,
- icon: 'success',
- mask: true
- })
- let data = JSON.stringify(res.data)
- setTimeout(() => {
- uni.redirectTo({
- url: `/pages/shopInfo/shopInfo?type=1&data=${data}`
- })
- }, 1500)
- } else {
- uni.showToast({
- title: res.message,
- icon: 'none',
- mask: true
- })
- }
- },
- // 业主绑定请求
- async handleBinding2() {
- const res = await this.$myRequest({
- url: '/mhotel/appcode.action',
- data: {
- code: this.code,
- admin_name: this.formName,
- password: this.formPassword
- }
- })
- // console.log(res)
- if (res.code === 200) {
- uni.showToast({
- title: res.message,
- icon: 'success',
- mask: true
- })
- let data = JSON.stringify(res.data)
- setTimeout(() => {
- uni.redirectTo({
- url: `/pages/shopInfo/shopInfo?type=2&data=${data}`
- })
- }, 1500)
- } else {
- uni.showToast({
- title: res.message,
- icon: 'none',
- mask: true
- })
- }
- },
- // 商户解绑请求
- async handleUnbind() {
- const res = await this.$myRequest({
- url: '/mhotel/appuncode_ma.action',
- data: {
- code: this.code,
- admin_name: this.formName,
- password: this.formPassword
- }
- })
- // console.log(res)
- if (res.code === 200) {
- uni.showToast({
- title: res.message,
- icon: 'success',
- mask: true
- })
- setTimeout(() => {
- uni.switchTab({
- url: '/pages/my/my'
- })
- }, 1500)
- } else {
- uni.showToast({
- title: res.message,
- icon: 'none',
- mask: true
- })
- }
- },
- // 业主解绑请求
- async handleUnbind2() {
- const res = await this.$myRequest({
- url: '/mhotel/appuncode.action',
- data: {
- code: this.code,
- admin_name: this.formName,
- password: this.formPassword
- }
- })
- // console.log(res)
- if (res.code === 200) {
- uni.showToast({
- title: res.message,
- icon: 'success',
- mask: true
- })
- setTimeout(() => {
- uni.switchTab({
- url: '/pages/my/my'
- })
- }, 1500)
- } else {
- uni.showToast({
- title: res.message,
- icon: 'none',
- mask: true
- })
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- display: flex;
- flex-direction: column;
- align-items: center;
- height: 100vh;
- background-color: #fff;
- img {
- margin-top: 20rpx;
- width: 347rpx;
- height: 387rpx;
- }
- .form {
- box-sizing: border-box;
- padding: 0 30rpx;
- margin-top: 35rpx;
- width: 690rpx;
- height: 548rpx;
- border-radius: 23rpx;
- box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.25);
- .form_title {
- line-height: 120rpx;
- font-size: 32rpx;
- font-weight: bold;
- }
- .form_name {
- display: flex;
- align-items: center;
- font-size: 28rpx;
- .name_input {
- display: flex;
- align-items: center;
- box-sizing: border-box;
- padding: 0 24rpx;
- margin-left: 25rpx;
- width: 545rpx;
- height: 80rpx;
- border-radius: 15rpx;
- border: 1rpx solid #a6a6a6;
- input {
- width: 100%;
- }
- }
- }
- .form_password {
- display: flex;
- align-items: center;
- margin-top: 46rpx;
- font-size: 28rpx;
- .password_input {
- display: flex;
- align-items: center;
- box-sizing: border-box;
- padding: 0 24rpx;
- margin-left: 25rpx;
- width: 545rpx;
- height: 80rpx;
- border-radius: 15rpx;
- border: 1rpx solid #a6a6a6;
- input {
- width: 100%;
- }
- }
- }
- .form_msg {
- margin-top: 23rpx;
- height: 32rpx;
- color: #d43030;
- font-size: 24rpx;
- text-align: center;
- }
- .form_btn {
- display: flex;
- justify-content: center;
- align-items: center;
- margin-top: 28rpx;
- width: 624rpx;
- height: 96rpx;
- border-radius: 64rpx;
- color: #fff;
- font-size: 32rpx;
- background-color: #096562;
- }
- }
- }
- </style>
|