123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- // pages/mine/mine.js
- var app = getApp();
- var utils = require("../../utils/http")
- var qqmapsdk;
- Page({
- data: {
- top: app.globalData.statusBarHeight,
- hgt: app.globalData.titleBarHeight,
- imgUrl: app.globalData.imgUrl,
- company: '',
- department: '',
- personName: '',
- post: '',
- wxnum: '',
- email: '',
- brief: '',
- headimgurl: '',
- phone: '',
- disabled: false,
- user: '',
- disabledname: false
- },
- onLoad: function (opts) {
- var that = this;
- if (!!opts.uid) {
- that.setData({
- user: opts.uid
- })
- } else {
- that.setData({
- user: app.globalData.personMsg.id
- })
- }
- that.personmsg();
- },
- personmsg: function () {
- var that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/card/info',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- user: that.data.user
- },
- success: function (res) {
- if (res.data.code == '0') {
- that.setData({
- headimgurl: res.data.data.headimgurl,
- company: res.data.data.company_name,
- department: res.data.data.department,
- personName: res.data.data.name,
- post: res.data.data.position,
- wxnum: res.data.data.wx,
- email: res.data.data.email,
- brief: res.data.data.brief,
- phone: res.data.data.phone
- })
- if (res.data.data.joinCompany == '1') {
- that.setData({
- disabledname: true
- })
- } else {
- that.setData({
- disabledname: false
- })
- }
- }
- }
- })
- },
- onReady: function () {
- },
- companyTap: function (e) {
- this.setData({
- company: e.detail.value
- })
- },
- departmentTap: function (e) {
- this.setData({
- department: e.detail.value
- })
- },
- nameTap: function (e) {
- this.setData({
- personName: e.detail.value
- })
- },
- phoneTap: function (e) {
- this.setData({
- phone: e.detail.value
- })
- },
- postTap: function (e) {
- this.setData({
- post: e.detail.value
- })
- },
- wxnumTap: function (e) {
- this.setData({
- wxnum: e.detail.value
- })
- },
- emailTap: function (e) {
- this.setData({
- email: e.detail.value
- })
- },
- briefTap: function (e) {
- this.setData({
- brief: e.detail.value
- })
- },
- onPlay: function () {
- },
- saveTap: function () {
- var that = this;
- if (!that.data.company) {
- wx.showToast({
- title: "公司名不能为空",
- icon: "none",
- duration: 2000
- });
- return false;
- }
- if (!that.data.department) {
- wx.showToast({
- title: "部门不能为空",
- icon: "none",
- duration: 2000
- });
- return false;
- }
- if (!that.data.post) {
- wx.showToast({
- title: "职务不能为空",
- icon: "none",
- duration: 2000
- });
- return false;
- }
- if (!that.data.personName) {
- wx.showToast({
- title: "姓名不能为空",
- icon: "none",
- duration: 2000
- });
- return false;
- }
- if (!that.data.wxnum) {
- wx.showToast({
- title: "微信号不能为空",
- icon: "none",
- duration: 2000
- });
- return false;
- }
- if (!that.data.email) {
- wx.showToast({
- title: "邮箱不能为空",
- icon: "none",
- duration: 2000
- });
- return false;
- }
- if (!that.data.brief) {
- wx.showToast({
- title: "简介不能为空",
- icon: "none",
- duration: 2000
- });
- return false;
- }
- if (!that.data.phone) {
- wx.showToast({
- title: "手机号不能为空",
- icon: "none",
- duration: 2000
- });
- return false;
- }
- wx.showLoading({
- title: '加载中...',
- })
- that.setData({
- disabled: true
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/card/save',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- company_name: that.data.company,
- department: that.data.department,
- position: that.data.post,
- phone: that.data.phone,
- name: that.data.personName,
- wx: that.data.wxnum,
- email: that.data.email,
- brief: that.data.brief,
- },
- success: function (res) {
- if (res.data.code == '0') {
- wx.showToast({
- title: res.data.msg,
- icon: "none",
- duration: 2000
- });
- setTimeout(function () {
- wx.navigateBack();
- }, 1000)
- } else {
- that.setData({
- disabled: false
- })
- }
- },
- fail() {
- that.setData({
- disabled: false
- })
- }
- })
- },
- onPlayNav: function () {
- },
- onShow: function () {
- this.setData({
- top: app.globalData.statusBarHeight,
- hgt: app.globalData.titleBarHeight,
- })
- },
- backTap: function () {
- wx.navigateBack();
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage: function () {
- // }
- })
|