mycode.vue 6.4 KB

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