mycode.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view>
  3. <image class="echo-mycodeban" mode="widthFix" :src="param.mycodeban"></image>
  4. <view class="bg-blue padding-lr-xl padding-bottom-xl" :style="'min-height: calc(100vh); background-color: '+param.mycodecolor+';'">
  5. <view class="text-center bg-white margin-bottom-lg radius">
  6. <view class="text-xl padding-lr padding-top">
  7. <text class="text-black">我的邀请码</text>
  8. </view>
  9. <view class="text-center solid-bottom text-sm padding">
  10. <text class="text-grey">请被邀请人扫码完成注册登录</text>
  11. </view>
  12. <view class="padding">
  13. <image class="codeimg" mode="widthFix" @click="refCode" :src="userinfo.wxampcode"></image>
  14. <view class="flex flex-direction">
  15. <button class="cu-btn round bg-gray margin-top-sm lg" @tap="saveImage">保存我的邀请码</button>
  16. </view>
  17. <view class="flex flex-direction">
  18. <button class="cu-btn round bg-green margin-tb-sm lg" open-type="share">微信邀请</button>
  19. </view>
  20. </view>
  21. </view>
  22. <scroll-view scroll-x class="bg-white radius nav">
  23. <view class="flex text-center solid-bottom">
  24. <view class="cu-item flex-sub" :class="1==TabCur?'text-orange cur':''" @tap="tabSelect" :data-id="1">
  25. 邀请排行
  26. </view>
  27. <!-- <view class="cu-item flex-sub" :class="2==TabCur?'text-orange cur':''" @tap="tabSelect" :data-id="2">
  28. 推荐注册
  29. </view> -->
  30. </view>
  31. </scroll-view>
  32. <view class="cu-list radius menu" v-if="1==TabCur">
  33. <block v-for="(item,index) in plist" :key="index">
  34. <view class="cu-item">
  35. <view class="action padding-right-lg text-red" v-if="index==0">{{index+1}}</view>
  36. <view class="action padding-right-lg text-orange" v-else-if="index==1">{{index+1}}</view>
  37. <view class="action padding-right-lg text-yellow" v-else-if="index==2">{{index+1}}</view>
  38. <view class="action padding-right-lg text-black" v-else>{{index+1}}</view>
  39. <view class="content padding-tb-sm padding-right-sm">
  40. <view class="text-black">{{item.realname}}</view>
  41. <view class="text-gray text-sm">{{item.mobile}}</view>
  42. </view>
  43. <view class="action text-black">{{item.partnumber}} 人</view>
  44. </view>
  45. </block>
  46. <view class="cu-item">
  47. <view class="content padding-xs text-center">
  48. <text class="text-gray text-center text-sm">目前只显示前 {{pcount}} 名。</text>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="bg-white padding radius" v-if="2==TabCur">
  53. <form>
  54. <view class="cu-form-group">
  55. <view class="title">姓名</view>
  56. <input placeholder="请输入推荐人姓名" @input="bindInput" data-val="realname" :value="forminfo.realname"></input>
  57. </view>
  58. <view class="cu-form-group solids-bottom">
  59. <view class="title">手机号</view>
  60. <input placeholder="请输入推荐人手机号" @input="bindInput" data-val="mobile" :value="forminfo.mobile"></input>
  61. </view>
  62. <view class="padding flex flex-direction">
  63. <button class="cu-btn bg-orange margin-tb-sm lg" @tap="regUser">确认提交</button>
  64. </view>
  65. </form>
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. var _this;
  72. export default {
  73. data() {
  74. return {
  75. param: {},
  76. userinfo: {},
  77. TabCur: 1,
  78. plist: [],
  79. pcount: 0,
  80. isRotate: false,
  81. forminfo: {
  82. realname: "",
  83. mobile: ""
  84. }
  85. };
  86. },
  87. onLoad: function(){
  88. _this = this;
  89. _this.userinfo = _this.checkLogin("/pages/my/mycode");
  90. if (_this.userinfo===false){
  91. return false;
  92. }
  93. if (_this.userinfo.wxampcode==""){
  94. _this.refCode();
  95. }
  96. _this.$req.ajax({
  97. path: "my/pagecode",
  98. data: {}
  99. }).then((data) => {
  100. _this.param = data.param;
  101. _this.plist = data.plist;
  102. _this.pcount = data.pcount;
  103. }).catch((err) => {
  104. uni.showModal({
  105. title: '信息提示',
  106. content: err,
  107. showCancel: false
  108. });
  109. });
  110. },
  111. onShareAppMessage: function(res) {
  112. return {
  113. title: _this.param.mycodetil,
  114. path: "/pages/login/sharepuser?parentid="+_this.userinfo.id,
  115. imageUrl: _this.param.mycodepic
  116. }
  117. },
  118. methods: {
  119. saveImage: function() {
  120. uni.downloadFile({
  121. url: _this.userinfo.wxampcode, //仅为示例,并非真实的资源
  122. success: (res) => {
  123. if (res.statusCode === 200) {
  124. uni.saveImageToPhotosAlbum({
  125. filePath: res.tempFilePath,
  126. success: function () {
  127. uni.showModal({
  128. title: '信息提示',
  129. content: "邀请码已保存到手机相册,注意查收。",
  130. showCancel: false
  131. });
  132. }
  133. });
  134. }
  135. }
  136. });
  137. },
  138. refCode: function() {
  139. _this.$req.ajax({
  140. path: "my/refcode",
  141. data: {
  142. userid: _this.userinfo.id
  143. }
  144. }).then((data) => {
  145. _this.userinfo.wxampcode = data.wxampcode+"?" + Math.random();
  146. uni.setStorageSync('userinfo', _this.userinfo);
  147. }).catch((err) => {
  148. uni.showModal({
  149. title: '信息提示',
  150. content: err,
  151. showCancel: false
  152. });
  153. });
  154. },
  155. tabSelect: function(e) {
  156. _this.TabCur = e.currentTarget.dataset.id;
  157. },
  158. regUser: function() {
  159. if(_this.isRotate){
  160. return false;
  161. }
  162. _this.isRotate = true;
  163. _this.$req.ajax({
  164. path: "my/reguser",
  165. data: {
  166. userid: _this.userinfo.id,
  167. realname: _this.forminfo.realname,
  168. mobile: _this.forminfo.mobile
  169. }
  170. }).then((data) => {
  171. uni.showModal({
  172. title: '信息提示',
  173. content: "推荐注册成功。",
  174. showCancel: false,
  175. success: function(res) {
  176. if (res.confirm) {
  177. _this.forminfo = {
  178. realname: "",
  179. mobile: ""
  180. };
  181. }
  182. }
  183. });
  184. _this.isRotate = false;
  185. }).catch((err) => {
  186. uni.showModal({
  187. title: '信息提示',
  188. content: err,
  189. showCancel: false
  190. });
  191. _this.isRotate = false;
  192. });
  193. },
  194. bindInput: function(e) {
  195. var dataval = e.currentTarget.dataset.val;
  196. _this.forminfo[dataval] = e.detail.value;
  197. }
  198. }
  199. }
  200. </script>
  201. <style>
  202. .echo-mycodeban{ width: 100%; display: block; }
  203. </style>