mendianSPFenlei.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view>
  3. <customNav :shownav="true" :title="$t('index.goodsfenlei')" titledetl="" addBT='1' v-on:Enavbarsel="addmendianfl"></customNav>
  4. <!-- <view style="margin-top: 20rpx;">
  5. <uni-list v-for="item in shangpinfenlei">
  6. <uni-list-item :show-extra-icon="false" showArrow :title="item.name" :rightText="$t('mend.dianjibj')" @click="listClick(item.id,item.name)" link/>
  7. </uni-list>
  8. </view> -->
  9. <view style="margin-top: 30rpx;">
  10. <!-- <view class="contentInRowL" style="margin-left: 30rpx;margin-top: 60rpx;">
  11. <text>{{$t('shangpin.fenleiyuyan')}}: {{langtext}}</text>
  12. <uni-icons style="margin-left: 16rpx;" custom-prefix="custom-icon" color="#006AFF" type="loop" size="26" @click="changeLang"></uni-icons>
  13. </view> -->
  14. <view v-for="item in shangpinfenlei">
  15. <view class="contentInRowS bottomline">
  16. <text class="textfontB5" style="padding-left: 30rpx;">{{item.name}}</text>
  17. <view style="padding-right: 30rpx;">
  18. <text class="deleBt" @click="deleClick(item.id)">{{$t('index.sanchu')}}</text>
  19. <text class="edeatBt" @click="listClick(item.id,item.name,item.sort)">{{$t('mend.dianjibj')}}</text>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view>
  25. <!-- 输入框示例 -->
  26. <uni-popup ref="inputDialog" type="dialog">
  27. <view class="contentColumnC fenleiPop">
  28. <text class="textfontB1" style="width: 80%;text-align: center;margin-top: 16rpx;">{{$t('mend.tianjiafl')}}</text>
  29. <view class="contentInRowL" style="width: 80%;">
  30. <input class="noinputV" type="text" :value="name" :placeholder="$t('mend.qingshurflmc')" @input="inputName">
  31. </view>
  32. <view class="contentColumn" style="width: 80%;">
  33. <input class="noinputV" type="text" :value="sorft" :placeholder="$t('mend.qingshurflpx')" @input="inputSorft">
  34. <text style="font-size: 24rpx;color: darkgray;margin-top: 8rpx;">{{$t('mend.fenleixhsm')}}</text>
  35. </view>
  36. <view class="contentInRowS" style="width: 80%;margin-top: 30rpx;">
  37. <text class="" @click="dialogInputcancle">{{$t('order.quxiao')}}</text>
  38. <text class="" @click="dialogInputConfirm">{{$t('comp.queren')}}</text>
  39. </view>
  40. <view style="height: 30rpx;"></view>
  41. </view>
  42. <!-- <uni-popup-dialog ref="inputClose" mode="input" :title="$t('mend.tianjiafl')" :value="name"
  43. :placeholder="$t('mend.qingshurflmc')" :cancelText="$t('order.quxiao')" :confirmText="$t('comp.queren')" @confirm="dialogInputConfirm"></uni-popup-dialog> -->
  44. </uni-popup>
  45. </view>
  46. <uni-popup ref="langPop">
  47. <view class="contentColumnC" style="width: 100%;background-color: white;">
  48. <text class="poptextList" style="margin-top: 20rpx;" @click="langSel('0')">Tiếng Việt</text>
  49. <text class="poptextList" @click="langSel('2')">简体中文</text>
  50. <text class="poptextList" @click="langSel('3')">繁體中文</text>
  51. </view>
  52. </uni-popup>
  53. </view>
  54. </template>
  55. <script>
  56. import api from "@/pages/api/api.js";
  57. export default {
  58. data() {
  59. return {
  60. shangpinfenlei: [],
  61. id:-1,
  62. mendid:0,
  63. name:'',
  64. sorft:'',
  65. lang:'0',
  66. langtext:'Tiếng Việt'
  67. }
  68. },
  69. onLoad(option) {
  70. this.mendid=option.mendid;
  71. var language = uni.getStorageSync('language');
  72. if(language=='yuenan'){
  73. this.lang='0';
  74. this.langtext='Tiếng Việt';
  75. }
  76. if(language=='zh-Hans'){
  77. this.lang='2';
  78. this.langtext='简体中文';
  79. }
  80. if(language=='zh-Hant'){
  81. this.lang='3';
  82. this.langtext='繁體中文';
  83. }
  84. },
  85. onShow() {
  86. this.getmendianshangpinFL(this.mendid);
  87. },
  88. methods: {
  89. listClick(id,name,sort){
  90. this.id=id;
  91. this.name=name;
  92. this.sorft=sort;
  93. this.$refs.inputDialog.open();
  94. },
  95. changeLang(){
  96. this.$refs.langPop.open('bottom');
  97. },
  98. langSel(index){
  99. this.lang=index;
  100. if(this.lang=='0'){
  101. this.langtext='Tiếng Việt';
  102. }
  103. if(this.lang=='2'){
  104. this.langtext='简体中文';
  105. }
  106. if(this.lang=='3'){
  107. this.langtext='繁體中文';
  108. }
  109. this.$refs.langPop.close();
  110. this.getmendianshangpinFL(this.mendid);
  111. },
  112. addmendianfl(){
  113. this.id=-1;
  114. this.name='';
  115. this.$refs.inputDialog.open();
  116. },
  117. inputName(v){
  118. this.name = v.target.value;
  119. },
  120. inputSorft(v){
  121. this.sorft = v.target.value;
  122. },
  123. dialogInputConfirm(){
  124. console.log('点击确认')
  125. this.$refs.inputDialog.close();
  126. this.addfenleiname(this.name);
  127. },
  128. dialogInputcancle(){
  129. console.log('点击取消')
  130. this.$refs.inputDialog.close();
  131. },
  132. getmendianshangpinFL(id){
  133. api('getmendianshangpinFL',{
  134. id:id,
  135. language:this.lang
  136. },r=>{
  137. console.log(r);
  138. this.shangpinfenlei=r.data.data;
  139. },failc=>{
  140. //console.log('getadvertis----',failc)
  141. })
  142. },
  143. addfenleiname(name){
  144. var data;
  145. if(this.sorft==''){
  146. this.sorft=0;
  147. }
  148. if(this.id<0){
  149. data={
  150. mendid: this.mendid,
  151. name: name,
  152. img: "",
  153. sort:this.sorft,
  154. language:this.lang
  155. }
  156. }
  157. else{
  158. data={
  159. mendid: this.mendid,
  160. name: name,
  161. img: "",
  162. sort:this.sorft,
  163. id:this.id,
  164. language:this.lang
  165. }
  166. }
  167. console.log('addfenleiname:name',name);
  168. api('addmendianfenlei',data,
  169. r=>{
  170. console.log(r);
  171. this.getmendianshangpinFL(this.mendid);
  172. },failc=>{
  173. //console.log('getadvertis----',failc)
  174. })
  175. },
  176. deleClick(index){
  177. var that = this;
  178. uni.showModal({
  179. cancelText: that.$t('order.quxiao'), // 取消按钮的文字
  180. confirmText: that.$t('comp.queren'), // 确认按钮的文字
  181. title: that.$t('api.message'),
  182. content: that.$t('index.sanchushpfenl'),
  183. success: function (res) {
  184. if (res.confirm) { //这里是点击了确定以后
  185. that.delefenlei(index);
  186. } else { //这里是点击了取消以后
  187. console.log('用户点击取消')
  188. }
  189. }
  190. })
  191. },
  192. delefenlei(index){
  193. api('delefenlei',{
  194. id:index
  195. },
  196. r=>{
  197. console.log(r)
  198. if(r.data.code==200){
  199. uni.showToast({
  200. title:this.$t('index.sanchuchengg'),
  201. icon:"none",
  202. duration: 1500
  203. })
  204. this.getmendianshangpinFL(this.mendid);
  205. }
  206. else{
  207. uni.showToast({
  208. title:r.data.msg,
  209. icon:"none"
  210. })
  211. }
  212. },failc=>{
  213. uni.showToast({
  214. title:failc,
  215. icon:"none"
  216. })
  217. })
  218. },
  219. }
  220. }
  221. </script>
  222. <style>
  223. .bottomline{
  224. height: 90rpx;
  225. border: solid lightgray;
  226. border-width: 0px 0px 2rpx 0px;
  227. }
  228. .deleBt{
  229. margin-right: 46rpx;
  230. color: #006AFF;
  231. text-decoration:underline;
  232. }
  233. .edeatBt{
  234. color:darkblue;
  235. text-decoration:underline;
  236. }
  237. .fenleiPop{
  238. width:660upx;
  239. background-color:white;
  240. border-radius: 8rpx;
  241. }
  242. .noinputV{
  243. margin-top: 30rpx;
  244. height: 46rpx;
  245. font-size: 28rpx;
  246. width: 100%;
  247. color: black;
  248. border: 1rpx solid lightgray;
  249. }
  250. .poptextList{
  251. width: 400rpx;
  252. height: 80rpx;
  253. text-align: center;
  254. line-height: 80rpx;
  255. border: solid lavender;
  256. border-width: 0px 0px 1rpx 0px;
  257. }
  258. </style>