my.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template name="my">
  2. <view>
  3. <view class="grace-list">
  4. <view class="grace-list-items">
  5. <view class="grace-list-image ucenter-face grace-relative">
  6. <image class="grace-list-image ucenter-face-image" :src="fetch.user.avatar" mode="widthFix" @click="avatarSet(0)"></image>
  7. <avatar @upload="avatarUpload" ref="avatar"></avatar>
  8. </view>
  9. <view class="grace-list-body">
  10. <view class="grace-list-title">
  11. <text class="grace-list-title-text">{{fetch.user.username}}<text v-if="fetch.user.title" style="margin-left:10rpx">({{fetch.user.title}})</text> </text>
  12. </view>
  13. <view class="grace-list-body-desc">{{fetch.user.info}}</view>
  14. </view>
  15. <text class="grace-list-arrow-right grace-icons icon-arrow-right" style="display:none;"></text>
  16. </view>
  17. </view>
  18. <view class="ucenter-line" v-if="fetch.num.length > 0"></view>
  19. <view v-if="fetch.num.length > 0">
  20. <graceBoxBanner :items="fetch.num" @taped="showScore"></graceBoxBanner>
  21. </view>
  22. <graceDialog :isTitle="true" :title="scoreTitle" :isCloseBtn="true" :show="score" closeBtnColor="#FFFFFF" v-on:closeDialog="closeScore">
  23. <scroll-view :scroll-y="true" class="padding" slot="content" style="height:800rpx;">
  24. <view class="zhList padding margin-tb" v-for="(v, k) in fetch.score" :key="k">
  25. <view class="flex justify-between">
  26. <view class="text-black font-30 block margin-bottom-xs text-bold">{{v.title}}</view>
  27. <view class="text-bold text-red" v-if="v.status == 2">-{{v.num}}</view>
  28. <view class="text-bold text-blue" v-if="v.status == 1">+{{v.num}}</view>
  29. </view>
  30. <view class="text-999 flex justify-between margin-top align-center">
  31. <text class="font-24">余额:{{v.total}}</text>
  32. <text class="font-24 block">{{v.cdate}}</text>
  33. </view>
  34. </view>
  35. </scroll-view>
  36. <view slot="btns" class="grace-space-between">
  37. <text class="grace-dialog-buttons" @tap="closeScore">关闭</text>
  38. </view>
  39. </graceDialog>
  40. <view class="ucenter-line"></view>
  41. <view class="grace-list grace-margin-top">
  42. <view class="card-bottom">
  43. <!-- 顶部分页栏 -->
  44. <view class="top-tab">
  45. <view :class="['tab-item flex-center', activeTab == k ? 'active' : '']" @tap="handleTab(k)" v-for="(v, k) in cate" :key="k">{{ v }}</view>
  46. </view>
  47. <view class="scroll-wrapper">
  48. <view class="margin-bottom">
  49. <view class="cu-list menu-avatar" v-if="activeTab == 1">
  50. <view class="cu-item " v-for="(v, k) in fetch.order" :key="k">
  51. <view class="cu-avatar radius lg" :style="{backgroundImage:'url('+v.pic+')'}"></view>
  52. <view class="content">
  53. <view class="text-pink"><view class="text-cut">{{v.name}}</view></view>
  54. <view class="text-gray text-sm flex"> <view class="text-cut">{{v.date}}</view></view>
  55. </view>
  56. <view class="action" style="width:120rpx;">
  57. <view class="text-grey text-xs">{{v.price}}</view>
  58. <view class="cu-tag round bg-red sm" v-if="v.shape == 2">查看详情</view>
  59. <view class="cu-tag round bg-black sm" v-else-if="v.mode == 2">查看自提码</view>
  60. <view class="cu-tag round bg-blue sm" v-else>{{v.status_name}}</view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="cu-list menu-avatar" v-if="activeTab == 2">
  65. <view class="cu-item" v-for="(v, k) in fetch.chat" :key="k" @click="goChat(v.uid, v.user.username)">
  66. <view class="cu-avatar round lg" :style="{backgroundImage:'url('+v.user.avatar+')'}">
  67. <view class="cu-tag badge" style="display:none;">99+</view>
  68. </view>
  69. <view class="content">
  70. <view class="text-grey">
  71. <view class="text-cut">{{v.user.username}}</view>
  72. <view class="cu-tag round bg-orange sm" v-if="v.user.title">{{v.user.title}}</view>
  73. </view>
  74. <view class="text-gray text-sm flex" v-if="v.chat.text">
  75. <view class="text-cut">
  76. {{v.chat.text}}
  77. </view>
  78. </view>
  79. </view>
  80. <view class="action" style="width: auto;">
  81. <view class="cu-tag round text-grey sm">{{v.chat.day}}</view>
  82. <view class="text-grey text-xs">{{v.chat.date}}</view>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="cu-list menu-avatar" v-if="activeTab == 0">
  87. <form @submit="formSubmit" class="grace-form grace-margin-top">
  88. <view class="grace-form-item grace-border-b">
  89. <text class="grace-form-label">昵称</text>
  90. <view class="grace-form-body">
  91. <input type="text" class="grace-form-input" name="name" placeholder="请填写有趣儿的昵称" v-model="fetch.user.username"></input>
  92. </view>
  93. </view>
  94. <view class="grace-form-item grace-border-b">
  95. <text class="grace-form-label">头衔</text>
  96. <view class="grace-form-body">
  97. <input type="text" class="grace-form-input" name="title" placeholder="请填写头衔" v-model="fetch.user.title"></input>
  98. </view>
  99. </view>
  100. <view class="grace-form-item grace-border-b">
  101. <text class="grace-form-label">签名</text>
  102. <view class="grace-form-body">
  103. <input type="text" class="grace-form-input" name="info" placeholder="请填写签名" v-model="fetch.user.info"></input>
  104. </view>
  105. </view>
  106. <view style="padding:30rpx 0;">
  107. <button formType="submit" type="primary" class="grace-button grace-border-radius">保存</button>
  108. </view>
  109. </form>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. </template>
  117. <script>
  118. var graceChecker = require("@/lib/graceUI/jsTools/graceChecker.js");
  119. import avatar from "@/lib/yq-avatar/yq-avatar.vue";
  120. export default {
  121. name: "cate",
  122. props: {
  123. content_id : {
  124. type : String,
  125. value : null
  126. },
  127. width : {
  128. type : String,
  129. default : '100%'
  130. },
  131. param : {},
  132. index : 0
  133. },
  134. data() {
  135. return {
  136. fetch : {
  137. user : {},
  138. num : [],
  139. order : [],
  140. chat : [],
  141. score : [],
  142. },
  143. activeTab : 0,
  144. //关系
  145. cate : [
  146. '个人资料', '购物订单'
  147. ],
  148. openAvatar : false,
  149. score : false,
  150. scoreTitle : '',
  151. }
  152. },
  153. mounted() {
  154. this.getData();
  155. },
  156. methods:{
  157. showScore : function(index) {
  158. console.info(index);
  159. var info = this.fetch.num[index];
  160. var title = info[2] + ':' + info[0];
  161. this.getScore(1, info[3], title);
  162. },
  163. getScore : function(page, method, title) {
  164. var self = this;
  165. this.Dever.page([page, 'score'], this, 'app/user/?l=api.score', {code:this.Dever.config.code,method:method}, function(t) {
  166. self.fetch.score = t.score;
  167. self.scoreTitle = title;
  168. self.score = true;
  169. });
  170. },
  171. closeScore : function() {
  172. this.score = false;
  173. },
  174. getData : function() {
  175. if (this.openAvatar) {
  176. return;
  177. } else {
  178. uni.stopPullDownRefresh();
  179. }
  180. var self = this;
  181. this.Dever.get(this, 'app/user/?l=api.get', {code:this.Dever.config.code, noloading:1});
  182. this.handleTab(this.activeTab);
  183. },
  184. getInfo : function(t) {
  185. //触底刷新
  186. this.handleTab(this.activeTab, 2);
  187. },
  188. getOrder : function(page) {
  189. this.Dever.page([page,'order'], this, 'app/user/?l=api.my_goods_order', {code:this.Dever.config.code, noloading:1});
  190. },
  191. getCommunity : function(page) {
  192. this.Dever.page([page,'chat'], this, 'app/user/?l=api.community', {code:this.Dever.config.code, noloading:1});
  193. },
  194. goChat : function(uid, username) {
  195. this.Dever.location('chat/user?uid=' + uid + '&code=' + this.Dever.config.code + '&title=' + username);
  196. },
  197. handleTab : function(k, t) {
  198. this.activeTab = k;
  199. if (!t) {
  200. t = 1;
  201. }
  202. if (k == 1) {
  203. this.getOrder(t);
  204. } else if(k == 2) {
  205. this.getCommunity(t);
  206. }
  207. },
  208. // 表单提交
  209. formSubmit : function(e) {
  210. var self = this;
  211. var rule = [
  212. { name: "name", checkType: "string", checkRule: "1,10", errorMsg: "昵称应为1-20个字符" },
  213. ];
  214. var formData = e.detail.value;
  215. var checkRes = graceChecker.check(formData, rule);
  216. if (checkRes) {
  217. formData.code = this.Dever.config.code;
  218. this.Dever.post('app/user/?l=api.up', formData, function(t) {
  219. self.Dever.alert('保存成功');
  220. });
  221. } else {
  222. self.Dever.alert(graceChecker.error);
  223. }
  224. },
  225. avatarUpload : function(e) {
  226. var self = this;
  227. this.openAvatar = false;
  228. this.Dever.uploadFile(e.path, 'avatar', 1, function(type, file) {
  229. self.fetch.user.avatar = file;
  230. self.Dever.post('app/user/?l=api.upAvatar', {avatar:file, noloading:1});
  231. });
  232. },
  233. avatarSet : function(index) {
  234. this.openAvatar = true;
  235. this.$refs.avatar.fChooseImg(index,{
  236. selWidth: "300rpx", selHeight: "300rpx",
  237. expWidth: '260rpx', expHeight: '260rpx',
  238. avatarSrc : this.fetch.user.avatar,
  239. bgImage : this.fetch.user.avatar,
  240. noTab : true,
  241. });
  242. }
  243. },
  244. components:{
  245. avatar
  246. }
  247. }
  248. </script>
  249. <style>
  250. .ucenter-face{width:100rpx !important; height:100rpx !important;}
  251. .ucenter-face-image{width:100rpx !important; height:100rpx !important;}
  252. .ucenter-line{height:12rpx; background-color:#f8f8f8; margin:16rpx 0;}
  253. .card-bottom {
  254. width: 100%;
  255. }
  256. .top-tab {
  257. display: flex;
  258. height: 120rpx;
  259. position: relative;
  260. top: 0;
  261. left: 0;
  262. width: 100%;
  263. z-index: 100;
  264. background-color: #ffffff;
  265. }
  266. .tab-item {
  267. flex: 1;
  268. color: #999;
  269. border-bottom: 4rpx solid #ececec;
  270. }
  271. .active {
  272. color: var(--mainColor);
  273. border-bottom: 4rpx solid var(--mainColor);
  274. }
  275. .flex-center {
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. }
  280. .grace-form-input {
  281. text-align: left;
  282. }
  283. .top{ background-color: #FB5858;}
  284. .btnOne{width:300rpx;height:80rpx;background:rgba(255,255,255,1);box-shadow:0rpx 2rpx 24rpx 0rpx rgba(251,88,88,1);border-radius:40rpx;}
  285. .line{width:1rpx;height:43rpx;background:rgba(255,255,255,1);}
  286. .zhList1{background:rgba(255,255,255,1);box-shadow:1px 5px 24px 0px rgba(161,161,161,0.38);border-radius:5px;}
  287. .zhList{background:rgba(255,255,255,1);border-bottom:1px solid rgba(161,161,161,0.38);}
  288. .text-91b{ color: #21A91B;}
  289. .text-101{ color: #FF0101;}
  290. .erro-404 {padding-bottom: 100upx;}
  291. .erro-404 image {width: 260upx; height: 260upx;}
  292. .font-24 {font-size: 12px;}
  293. .text-999 {color: #999;}
  294. </style>