吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1867|回复: 1
收起左侧

[求助] 来个大佬,帮忙改下微信小程序登录接口代码,改成开放希望熟悉小程序这一块的可以...

[复制链接]
坏小子8 发表于 2021-9-3 17:12
本帖最后由 坏小子8 于 2021-9-3 17:23 编辑

去掉后台搜索 改为开放注册


[HTML] 纯文本查看 复制代码
<view class="bgview">
        <view class="searchview" style="top:{{viewtop}}px;">
                <input focus class="inpt" maxlength="11" bindinput="inputtext" value="{{uname}}" placeholder="输入手机号" confirm-type="search"></input>
                <button disabled="{{jyss}}" style="width:30vw;height:5vh;margin-top:5vh;margin-left:5vw;float:left;vertical-align:middle;display:table-cell;" bindtap="sousuozz">搜 索</button>
        </view>
        <view wx:if="{{showuser}}" class="userview" style="top:calc(18vh + {{viewtop}}px);">
                <view class="userlistview">
                        姓 名 : {{userdata.ming}}
                </view>
                <view class="userlistview">
                        电 话 : {{userdata.tel}}
                </view>
                <view class="userlistview">
                        单 位 : {{userdata.dw}}
                </view>
                <view class="userlistview">
                        角 色 : {{userdata.js}}
                </view>
        </view>
</view>
<view class="zhuceview" wx:if="{{showuser}}" bindtap="guerenzhuce" style="top:calc({{viewtop}}px + 68vh);">
信息无误,确认注册。
</view>



[PHP] 纯文本查看 复制代码
<?php
include_once("../config.php");
//$id=$_GET['id'];
$uid=$_GET['uid'];
$uid = str_ireplace($search, '', $uid);
$id=intval($_GET['id']);
$sql="update user set openid='$uid' where id=$id";
mysqli_query($con,$sql);
if(mysqli_affected_rows($con)){
	die('{"status":"1","msg":"注册成功"}');
}else{
	die('{"status":"0","msg":"注册失败,请重试!"}');
}
?>





[Asm] 纯文本查看 复制代码
const app = getApp();
var istj = false;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    viewtop: 85, //搜索viewTOP值
    jyss: true, //禁用搜索按钮
    uname: '', //搜索框输入的内容
    showuser: false, //是否显示信息预览
    userdata: {} //服务器返回的用户信息
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var jn = wx.getMenuButtonBoundingClientRect();
    this.setData({
      viewtop: jn.bottom + 10
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
  inputtext: function (e) {
    var s = e.detail.value;
    if (s.length == 11) {
      var jyan = false;
    } else {
      var jyan = true;
    }
    this.setData({
      uname: s,
      jyss: jyan
    })
  },
  sousuozz: function () {
    var that = this;
    console.log(that.data.uname);
    var u = app.globalData.url + "searchuser.php";
    var d = {
      uname: that.data.uname
    }
    app.http(u, d).then(res => {
      that.setData({
        showuser: true,
        userdata: res
      })
    }).catch(res => {
      console.log('fail:', res);
      that.setData({
        showuser: false
      })
    }).finally(() => {
      console.log('finally:', "结束");
    })


  },
  guerenzhuce: function () {
    if (istj) {
      return;
    }
    istj = true;
    var that = this;


    if (that.data.userdata.zt == "1") {
      var url = '/pages/baoxiu/baoxiu';
      var tpid = ['KCYMFmJidhtFxWqgqOanxYJIKCFiMLBfBvsBj_jl9lE', 'IFTXxnpNSPkiN3H1WH4XTPlrzlDrq1ynJPNsIdUTLYs', 'ffRtOhQgIoJCgw7m4EEV1HJUO_P7OCJ-WddzYOMNWKI'];
    } else if (that.data.userdata.zt == "2") {
      var url = '/pages/guanli/guanli';
      var tpid = ['UZ985nAiJPyFHRgnH1Trub_uV6WQUuejRfy4BweuGpI', 'WFWgUVkLuYcRcDJewxMEgDuwP0e4uvC6E2cnjQAkTX4', 'Pdoi-osurewAKPVFo7UkfPHMC-wR_k8uvGG3BsmkNcY'];
    } else if (that.data.userdata.zt == "3") {
      var url = '/pages/weixiu/weixiu';
      var tpid = ['Pdoi-osurewAKPVFo7UkfPHMC-wR_k8uvGG3BsmkNcY', 'KCYMFmJidhtFxWqgqOanxYJIKCFiMLBfBvsBj_jl9lE', 'ffRtOhQgIoJCgw7m4EEV1HJUO_P7OCJ-WddzYOMNWKI'];
    } else {
      wx.showModal({
        title: '提示',
        content: '无效角色,请与管理员联系。',
        showCancel: false,
        success(res) {
          if (res.confirm) {
            istj = false;
            return;
          }
        }
      })
    }

    wx.requestSubscribeMessage({
      tmplIds: tpid,
      success(res) {
        console.log("success", res);


        var id = that.data.userdata.id;
        var d = {
          uid: wx.getStorageSync('uid'),
          id: id
        };
        var u = app.globalData.url + "reg.php";
        app.http(u, d).then(res => {
          wx.showToast({
            title: '注册成功',
            icon: 'success',
            duration: 2000
          });
          wx.setStorageSync('zt', that.data.userdata.zt);
          setTimeout(() => {
            wx.reLaunch({
              url: url
            })
          }, 2000);
        }).catch(res => {
          console.log('fail:', res);
        }).finally(() => {
          console.log('finally:', "结束");
          istj = false;
        })



      },
      fail(res) {
        console.log("fail", res);
        istj = false;
      }
    })
  }
})

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| 坏小子8 发表于 2021-9-3 18:44
坐等大佬 小白先行感谢
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-25 22:42

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表