editbusinesscard.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. // pages/mine/mine.js
  2. var app = getApp();
  3. var utils = require("../../utils/http")
  4. var qqmapsdk;
  5. Page({
  6. data: {
  7. top: app.globalData.statusBarHeight,
  8. hgt: app.globalData.titleBarHeight,
  9. imgUrl: app.globalData.imgUrl,
  10. company: '',
  11. department: '',
  12. personName: '',
  13. post: '',
  14. wxnum: '',
  15. email: '',
  16. brief: '',
  17. headimgurl: '',
  18. phone: '',
  19. disabled: false,
  20. user: '',
  21. disabledname: false
  22. },
  23. onLoad: function (opts) {
  24. var that = this;
  25. if (!!opts.uid) {
  26. that.setData({
  27. user: opts.uid
  28. })
  29. } else {
  30. that.setData({
  31. user: app.globalData.personMsg.id
  32. })
  33. }
  34. that.personmsg();
  35. },
  36. personmsg: function () {
  37. var that = this;
  38. utils.$post({
  39. url: app.globalData.webUrl + 'api/card/info',
  40. header: {
  41. 'Authorization': 'bearer ' + app.globalData.token
  42. },
  43. data: {
  44. user: that.data.user
  45. },
  46. success: function (res) {
  47. if (res.data.code == '0') {
  48. that.setData({
  49. headimgurl: res.data.data.headimgurl,
  50. company: res.data.data.company_name,
  51. department: res.data.data.department,
  52. personName: res.data.data.name,
  53. post: res.data.data.position,
  54. wxnum: res.data.data.wx,
  55. email: res.data.data.email,
  56. brief: res.data.data.brief,
  57. phone: res.data.data.phone
  58. })
  59. if (res.data.data.joinCompany == '1') {
  60. that.setData({
  61. disabledname: true
  62. })
  63. } else {
  64. that.setData({
  65. disabledname: false
  66. })
  67. }
  68. }
  69. }
  70. })
  71. },
  72. onReady: function () {
  73. },
  74. companyTap: function (e) {
  75. this.setData({
  76. company: e.detail.value
  77. })
  78. },
  79. departmentTap: function (e) {
  80. this.setData({
  81. department: e.detail.value
  82. })
  83. },
  84. nameTap: function (e) {
  85. this.setData({
  86. personName: e.detail.value
  87. })
  88. },
  89. phoneTap: function (e) {
  90. this.setData({
  91. phone: e.detail.value
  92. })
  93. },
  94. postTap: function (e) {
  95. this.setData({
  96. post: e.detail.value
  97. })
  98. },
  99. wxnumTap: function (e) {
  100. this.setData({
  101. wxnum: e.detail.value
  102. })
  103. },
  104. emailTap: function (e) {
  105. this.setData({
  106. email: e.detail.value
  107. })
  108. },
  109. briefTap: function (e) {
  110. this.setData({
  111. brief: e.detail.value
  112. })
  113. },
  114. onPlay: function () {
  115. },
  116. saveTap: function () {
  117. var that = this;
  118. if (!that.data.company) {
  119. wx.showToast({
  120. title: "公司名不能为空",
  121. icon: "none",
  122. duration: 2000
  123. });
  124. return false;
  125. }
  126. if (!that.data.department) {
  127. wx.showToast({
  128. title: "部门不能为空",
  129. icon: "none",
  130. duration: 2000
  131. });
  132. return false;
  133. }
  134. if (!that.data.post) {
  135. wx.showToast({
  136. title: "职务不能为空",
  137. icon: "none",
  138. duration: 2000
  139. });
  140. return false;
  141. }
  142. if (!that.data.personName) {
  143. wx.showToast({
  144. title: "姓名不能为空",
  145. icon: "none",
  146. duration: 2000
  147. });
  148. return false;
  149. }
  150. if (!that.data.wxnum) {
  151. wx.showToast({
  152. title: "微信号不能为空",
  153. icon: "none",
  154. duration: 2000
  155. });
  156. return false;
  157. }
  158. if (!that.data.email) {
  159. wx.showToast({
  160. title: "邮箱不能为空",
  161. icon: "none",
  162. duration: 2000
  163. });
  164. return false;
  165. }
  166. if (!that.data.brief) {
  167. wx.showToast({
  168. title: "简介不能为空",
  169. icon: "none",
  170. duration: 2000
  171. });
  172. return false;
  173. }
  174. if (!that.data.phone) {
  175. wx.showToast({
  176. title: "手机号不能为空",
  177. icon: "none",
  178. duration: 2000
  179. });
  180. return false;
  181. }
  182. wx.showLoading({
  183. title: '加载中...',
  184. })
  185. that.setData({
  186. disabled: true
  187. })
  188. utils.$post({
  189. url: app.globalData.webUrl + 'api/card/save',
  190. header: {
  191. 'Authorization': 'bearer ' + app.globalData.token
  192. },
  193. data: {
  194. company_name: that.data.company,
  195. department: that.data.department,
  196. position: that.data.post,
  197. phone: that.data.phone,
  198. name: that.data.personName,
  199. wx: that.data.wxnum,
  200. email: that.data.email,
  201. brief: that.data.brief,
  202. },
  203. success: function (res) {
  204. if (res.data.code == '0') {
  205. wx.showToast({
  206. title: res.data.msg,
  207. icon: "none",
  208. duration: 2000
  209. });
  210. setTimeout(function () {
  211. wx.navigateBack();
  212. }, 1000)
  213. } else {
  214. that.setData({
  215. disabled: false
  216. })
  217. }
  218. },
  219. fail() {
  220. that.setData({
  221. disabled: false
  222. })
  223. }
  224. })
  225. },
  226. onPlayNav: function () {
  227. },
  228. onShow: function () {
  229. this.setData({
  230. top: app.globalData.statusBarHeight,
  231. hgt: app.globalData.titleBarHeight,
  232. })
  233. },
  234. backTap: function () {
  235. wx.navigateBack();
  236. },
  237. /**
  238. * 生命周期函数--监听页面隐藏
  239. */
  240. onHide: function () {
  241. },
  242. /**
  243. * 生命周期函数--监听页面卸载
  244. */
  245. onUnload: function () {
  246. },
  247. /**
  248. * 页面相关事件处理函数--监听用户下拉动作
  249. */
  250. onPullDownRefresh: function () {
  251. },
  252. /**
  253. * 页面上拉触底事件的处理函数
  254. */
  255. onReachBottom: function () {
  256. },
  257. /**
  258. * 用户点击右上角分享
  259. */
  260. // onShareAppMessage: function () {
  261. // }
  262. })